【题意】一共有n个采石场,第i个采石场有mi辆货车,第一辆货车上有xi个石子,第二辆车上有xi+1个石子......第mi辆车上有xi+mi-1个石子,两人轮流拿石子,拿石子的规则符合Nim博弈规则,最后没发取石子的人为输。
【思路】在异或运算中,2^3=1,4^5=1,6^7=1.....即n^(n+1)=1当且仅当n为偶数。
【代码如下】
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int n;
const int N = 1e5+10;
LL ans=0;
struct node{
LL x,m;
}p[N];
int main(){
scanf("%d",&n);
for(int i = 0; i < n; i ++) scanf("%I64d%I64d",&p[i].x,&p[i].m);
for(int i = 0; i < n; i ++){
if(p[i].x % 2 == 0){
LL k = p[i].m/2;
if(k%2) ans ^= 1;
if(p[i].m%2) ans ^= (p[i].m+p[i].x-1);
}
else{
ans ^= p[i].x;
LL k = (p[i].m-1) / 2;
if(k%2) ans ^= 1;
if(p[i].m % 2 == 0) ans ^= (p[i].x + p[i].m - 1);
}
}
printf("%s\n",ans? "tolik" : "bolik");
return 0;
}