标签:algorithm minus stream main break ext else 函数 rom
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define ls i<<1 #define rs ls | 1 #define mid ((ll+rr)>>1) #define pii pair<int,int> #define MP make_pair typedef long long LL; const long long INF = 1e18+1LL; const double Pi = acos(-1.0); const int N = 5e5+10, M = 2e5+20, mod = 1e9+7, inf = 2e9; int sg[N],vis[N]; int main() { /*sg[0] = 0; for(int i = 1; i <= 100; ++i) { memset(vis,0,sizeof(vis)); for(int j = 0; j < i; ++j) vis[sg[j]] = 1; for(int j = 1; j <= i; ++j){ for(int jj = 1; jj <= i; ++jj) { for(int k = 1; k <= i; ++k) { if(j + jj + k == i) { vis[sg[j] ^ sg[jj] ^ sg[k]] = 1; } } } } for(int j = 0; j <= 1000; ++j) { if(!vis[j]) { sg[i] = j; break; } } cout<<i<<": " << sg[i]<<endl; } */ int T,n,x; scanf("%d",&T); while(T--) { scanf("%d",&n); int ans = 0; for(int i = 1; i <= n; ++i) { scanf("%d",&x); if((x+1)%8 == 0) { ans ^= (x+1); } else if(x % 8 == 0) ans ^= (x-1); else ans ^= x; } if(!ans) puts("Second player wins.");else puts("First player wins."); } return 0; }
HDU 5795 A Simple Nim 打表求SG函数的规律
标签:algorithm minus stream main break ext else 函数 rom
原文地址:http://www.cnblogs.com/zxhl/p/6011293.html