题意:Nimm Game
思路:Nimm Game
#include<iostream> #include<stdio.h> using namespace std; int main(){ int m,a[128],i,sum,ans; while(~scanf("%d",&m)&&m){ sum=0; for(i=0;i<m;++i){ scanf("%d",&a[i]); sum^=a[i]; } if(sum){ ans=0; for(i=0;i<m;++i) if((sum^a[i])<a[i])++ans;//优先级 printf("%d\n",ans); } else printf("0\n"); } return 0; }
另:HDU 1850 Being a Good Boy in Spring Festival(博弈·Nim游戏)
时间: 2024-10-13 16:19:21