基础威佐夫博弈,判断奇异局势即可,判断方式为k为两数之差绝对值,(sqrt(5) + 1) / 2 * k若等于两数小者则为奇异局势,也就是必败态.
#include#include #include #include #include using namespace std;int main(){ int a,b; while(~scanf("%d%d",&a,&b)) { int A = max(a,b); int B = min(a,b); int k = (A - B); A = int(k * (sqrt(5)+1)/2.0 ); if(A == B) { puts("0"); } else puts("1"); } return 0;}