JZYZOJ 2002 [cf] 石江豪pk李震 博弈论 sg函数

http://172.20.6.3/Problem_Show.asp?id=2002

https://blog.csdn.net/qq_24451605/article/details/50154973

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<cmath>
 5 #include<iostream>
 6 #include<map>
 7 using namespace std;
 8 int n,k;
 9 int f[10]={};
10 int dfs(int x){
11     if(x<6)return f[x];
12     if(x&1)return 0;
13     return dfs(x/2)==1?2:1;
14 }
15 int main(){
16     scanf("%d%d",&n,&k);
17     int ans=0,x;
18     for(int i=0;i<n;i++){
19         scanf("%d",&x);
20         if(k&1){
21             f[0]=f[2]=f[5]=0;f[1]=f[3]=1;f[4]=2;
22             if(x<6)ans^=f[x];
23             else ans^=x&1?0:dfs(x);
24         }
25         else{
26             f[0]=f[3]=0;
27             f[1]=f[4]=1;
28             f[2]=2;
29             if(x<5)ans^=f[x];
30             else ans^=x&1?0:1;
31         }
32     }
33     if(ans)printf("DaDeBuCuo
");
34     else printf("WoHenBaoQian
");
35     return 0;
36 }
View Code

原文地址:https://www.cnblogs.com/137shoebills/p/9087708.html