題目鏈結
題意:給你可以進行操作的步數,然後分別給你一堆石子,求解每一次給出的石子先者輸贏的結果,經典的sg博弈,sg具體不解釋
#include #include #include #define fin freopen("input.txt", "r", stdin)
using namespace std;
const int maxn = 1e4 + 10;
const int maxm = 1e2 + 5;
int s[maxm];
int sg[maxn], k;
int getsg(int m) ;
int i;
for(i = 0; i < k; i ++)
if(sg[m - s[i]] == -1)
hash[sg[m - s[i]]] = 1;
} for(i = 0; ; i ++) }}
int main()
sort(s, s + k);
int m, n;
scanf("%d", &m);
memset(sg, -1, sizeof(sg));
while(m --)
printf(sum ? "w" : "l");
} printf("\n");
} return 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函式
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...
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...