zoukankan      html  css  js  c++  java
  • 巴什博弈

    只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个,最后取光者胜。

    策略:

      先手: S  m+1-K  m+1-L

      后手: K   L    ....

    (K、L、S)均为1到m之间的任意数。

    公式:n=(m+1)*R+S;

    每次后手取完,先手会去试图将剩下的石子数构造成(m+1)的倍数,如果可以在后手第一次取完是构造,则必胜;反之则必输。

    Brave Game

     1 #include <bits/stdc++.h>
     2 #define scanf_d(a) scanf("%d",&a)
     3 #define scanf_dd(a,b) scanf("%d%d",&a,&b)
     4 #define maxn 100005
     5 using namespace std;
     6 int main()
     7 {
     8     int c;
     9     scanf_d(c);
    10     while(c--)
    11     {
    12         int n,m;
    13         scanf("%d%d",&n,&m);
    14         int mod=n%(m+1);
    15         if(mod>=1) puts("first");
    16         else puts("second");
    17         //printf("%d
    ",mod);
    18     }
    19     return 0;
    20 }
    View Code

    Good Luck in CET-4 Everybody!

    如果开局不是三的倍数,先手可以通过取适当数量的牌使得每次后手取得时候的牌数为3的倍数,故后手不可能取完,则先手胜。

    相反,如果开局是三的倍数,那么先手第一次无法取完,后手可以通过取适当数量的牌使得先手每次取时的牌数为3的倍数,故先手不可能取完,则后手胜。

     1 #include <bits/stdc++.h>
     2 #define scanf_d(a) scanf("%d",&a)
     3 #define scanf_dd(a,b) scanf("%d%d",&a,&b)
     4 #define maxn 100005
     5 //#define DEBUG
     6 using namespace std;
     7 int main()
     8 {
     9 #ifdef DEBUG
    10     freopen("Text.txt","r",stdin);
    11 #endif // DEBUG
    12     int n;
    13     while(~scanf_d(n) ){
    14         if(n % 3) {
    15             puts("Kiki");
    16         } else {
    17             puts("Cici");
    18         }
    19     }
    20     return 0;
    21 }
    View Code

    kiki's game

    找规律发现必败点的x,y坐标均为奇数。

     1 #include <bits/stdc++.h>
     2 #define scanf_d(a) scanf("%d",&a)
     3 #define scanf_dd(a,b) scanf("%d%d",&a,&b)
     4 #define maxn 100005
     5 using namespace std;
     6 int main()
     7 {
     8     int n,m;
     9     while(~scanf_dd(n,m)&&n&&m)
    10     {
    11         if(n%2 && m%2 ) printf("What a pity!
    ");
    12         else printf("Wonderful!
    ");
    13     }
    14     return 0;
    15 }
    View Code

    Public Sale

     1 #include <bits/stdc++.h>
     2 #define scanf_d(a) scanf("%d",&a)
     3 #define scanf_dd(a,b) scanf("%d%d",&a,&b)
     4 #define maxn 100005
     5 using namespace std;
     6 int main()
     7 {
     8     int n,m;
     9     while(~scanf_dd(n,m) ){
    10         if ( n <= m) {
    11             printf("%d",n);
    12             for(int i = n + 1; i <= m; i++)
    13                 printf(" %d",i);
    14             puts("");
    15         } else {
    16             int mod = n % (m + 1);
    17             if (mod >= 1) {
    18                 printf("%d",mod);
    19             puts("");
    20             } else {
    21                 puts("none");
    22             }
    23         }
    24     }
    25     return 0;
    26 }
    View Code

    悼念512汶川大地震遇难同胞——选拔志愿者

     1 #include <bits/stdc++.h>
     2 #define scanf_d(a) scanf("%d",&a)
     3 #define scanf_dd(a,b) scanf("%d%d",&a,&b)
     4 #define maxn 100005
     5 using namespace std;
     6 int main()
     7 {
     8     int t;
     9     scanf_d( t );
    10     while(t --) {
    11         int n, m;
    12         scanf_dd(n, m);
    13         if(n<=m) printf("Grass
    ");
    14         else {
    15             int mod = n % (m + 1);
    16             if(mod>=1) printf("Grass
    ");
    17             else printf("Rabbit
    ");
    18         }
    19     }
    20     return 0;
    21 }
    View Code
  • 相关阅读:
    Unity NGUI实现技能CD效果
    Unity NGUI中Anchor的用法
    Unity 技能按钮触发特效
    Unity NGUI 图集Atlas制作
    Unity NGUI 创建简单的按钮
    Unity 地形
    Unity GUI编程
    Unity 随机数的使用
    linux命令之pssh命令
    MySQL中SQL语句2
  • 原文地址:https://www.cnblogs.com/mile-star/p/10658573.html
Copyright © 2011-2022 走看看