題目:
多堆石子,先手勝為l,後手勝為w,
思路:
sg函式:
sg[i]=0表示先手必敗,否則必勝
有多堆石子,每次對sg[k]的值亦或(^)最終為0則必敗,否則必勝
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using
namespace
std;
#define mod 1000000007
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
typedef
long
long ll;
const
int n = 10008;
int s[108],t;
int sg[n];
bool hash[n];
void sg_solve(int *s,int t,int n) //n求解範圍 s陣列是可以每次取的值,t是s的長度。
}int main()
ans+=res?'w':'l';
}cout
0;}
HDU 1536 SG函式應用
只要構造好sg函式 就行 ac includeusing namespace std include int a 110 k k為全域性變數 int sg 10010 flag 110 void sg sg函式 int main if s cout w else cout l cout return...
hdu 1536 SG函式的應用
hdu 1536 submit time judge status pro.id exe.time exe.memory code len.language 2013 07 24 10 17 33 accepted 1536 109ms 476k 1174 b c include includeus...
hdu 1536 博弈SG函式
1 include 2 include 3 include 4 include 5 include 6 include 7 include 8 include 9 10using namespace std 1112 const int max 109 13 int num max sg max 1...