题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=135
Nim博弈,只不过现在一次最多取m个,能够想到巴什博弈。
巴什博弈的SG函数为SG(x) = x % (m+1)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
int t;
scanf("%d", &t);
while(t--) {
int n;
scanf("%d", &n);
int ans = 0;
while(n--) {
int x, y;
scanf("%d %d", &x, &y);
ans ^= (x % (y + 1));
}
if(ans) puts("Win");
else puts("Lose");
}
return 0;
}