2022/7/22
作者:
史一帆
,
2022-07-22 08:36:40
,
所有人可见
,
阅读 182
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <string>
#include <unordered_map>
using namespace std;
typedef long long LL;
const int N = 1010;
LL f[N];
set<LL> s;
void Init(){
f[1] = f[2] = 1;
s.insert(f[1]), s.insert(f[2]);
for (int i = 3; i < N; i ++ ){
f[i] = f[i - 1] + f[i - 2];
s.insert(f[i]);
}
}
int main(){
Init();
LL n;
while (cin >> n && n){
if (s.count(n))
puts("Second win");
else
puts("First win");
}
return 0;
}
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <string>
#include <unordered_map>
using namespace std;
typedef long long LL;
const int N = 1010;
int n, k, casei;
int main(){
int T;
cin >> T;
while (T -- ){
cin >> n >> k;
printf("Case %d: ", ++ casei);
if (k == 1){
if (n % 2) cout << "first";
else cout << "second";
} else{
if (k >= n) cout << "first";
else cout << "second";
}
cout << endl;
}
return 0;
}
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <string>
#include <unordered_map>
using namespace std;
typedef long long LL;
const int N = 110;
int sg[N];
bool st[N];
int mex(int x){
if (sg[x] != -1) return sg[x];
memset(st, false, sizeof st);
for (int i = 1; i <= x; i ++ )
st[mex(x - i)] = true;
for (int i = 1; i <= x - i; i ++ )
st[mex(i) ^ mex(x - i)] = true;
int i = 0;
while (st[i]) i ++ ;
return sg[x] = i;
}
int SG(int x){
if (x % 4 == 1 || x % 4 == 2) return x;
if (x % 4 == 3) return x + 1;
return x - 1;
}
int main(){
/*memset(sg, -1, sizeof sg);
for (int i = 0; i < N; i ++ ){
mex(i);
printf("sg[%d] = %d\n", i, sg[i]);
}*/
int T;
cin >> T;
while (T -- ){
int n;
cin >> n;
int ans = 0;
while (n -- ){
int x;
cin >> x;
ans ^= SG(x);
}
if (ans)
puts("Alice");
else
puts("Bob");
}
return 0;
}