zoukankan      html  css  js  c++  java
  • luogu P4018 Roy&October之取石子(博弈论)

    题意

    题解

    如果n是6的倍数,先手必败,否则先手必胜。

    因为6*x一定不是pk

    所以取得话会变成6*y+a的形式a=1,2,3,4,5;

    然后a一定为质数。我们把a取完就又成为了6*x的形式。

    又因为总数不断减少,所以6*x的局面是必败局面。

    做完这题让我想起了初中时就被这种问题被人坑过。

    然后博弈论可以先把SG的表打出来。

     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<cstring>
     5 #include<algorithm>
     6 using namespace std;
     7 int t,n;
     8 int main(){
     9     scanf("%d",&t);
    10     while(t--){
    11         scanf("%d",&n);
    12         if(n%6==0)printf("Roy wins!
    ");
    13         else printf("October wins!
    ");
    14     }
    15     return 0;
    16 }
  • 相关阅读:
    命令别名与历史命令
    Shell的变量功能
    Shell的变量功能
    认识BASH这个Shell
    vim程序编辑器
    其他vim使用注意事项
    vim的额外功能
    六、集合
    五、字典
    四、列表 元组
  • 原文地址:https://www.cnblogs.com/Xu-daxia/p/9566762.html
Copyright © 2011-2022 走看看