2019-03-09

1、 本游戏是一个二人游戏;
2、 有一堆石子一共有n个;
3、 两人轮流进行;
4、 每走一步可以取走1…m个石子;
5、 最先取光石子的一方为胜;

如果游戏的双方使用的都是最优策略,请输出哪个人能赢。

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t,n,m;
    cin>>t;
    while(t--)
        cin>>n>>m,(n%(m+1))?cout<<"first"<<endl:cout<<"second"<<endl;
    return 0;
}

1、 总共n张牌;
2、 双方轮流抓牌;
3、 每人每次抓牌的个数只能是2的幂次(即:1,2,4,8,16…)
4、 抓完牌,胜负结果也出来了:最后抓完牌的人为胜者;
每次都是Kiki先抓牌,请问谁能赢呢?如果Kiki能赢的话,请输出“Kiki”,否则请输出“Cici”,每个实例的输出占一行。

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,t;
    while(cin>>n)
    {
        t=0;
        for(int i=0;(1<<i)<=n;i++)
        {
            if((1<<i)&n)
                t++;
        }
        (t%2)?printf("Kiki"):printf("Cici");
        printf("\n");
    }
    return 0;
}

有n堆石子,第i堆有a[i]个,两人轮流取:

1)每一步应取走至少一枚石子;每一步只能从某一堆中取走部分或全部石子;

2)如果谁取到最后一枚石子就胜。

问是先手胜还是先手败?
输入数据多组,第一行一个n(n<=100),表示接下来有n堆石子,每堆a[i]个(a[i] < 1000000)。
如果是先手胜,则输出“Win”,否则输出“Lose”

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,ans,temp;
    while(cin>>n)
    {
        temp=0;
        for(int i=0;i<n;i++)
        {
            cin>>ans;
            temp^=ans;
        }
        temp?printf("Win"):printf("Lose");
        printf("\n");
    }
    return 0;
}

Description
有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。
Input
输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000。
Output
输出对应也有若干行,每行包含一个数字1或0,如果最后你是胜者,则为1,反之,则为0。

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n1,n2,temp;
    while(cin>>n1>>n2)
    {
        if(n1>n2) swap(n1,n2);
            temp=floor((n2-n1)*(1+sqrt(5.0))/2.0);
        temp==n1?printf("0"):printf("1");
        printf("\n");
    }
    return 0;
}

Let’s consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time.
For example “@@@” can be turned into “@@” or “@” or “@ @”(two piles). two people get apples one after another and the one who takes the last is
the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
Input
You will be given several cases. Each test case begins with a single number n (1 <= n <= 100), followed by a line with n numbers, the number of apples in each pile. There is a blank line between cases.
Output
If a winning strategies can be found, print a single line with “Yes”, otherwise print “No”.

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,x,tmp,flag;
    while(cin>>n)
    {
        tmp=0,flag=1;
        for(int i=0; i<n; i++)
        {
            cin>>x;
            if(x>1)
                flag=0;
            tmp^=x;
        }
        (!tmp&&flag)||(tmp&&!flag)?printf("Yes\n"):printf("No\n");
    }
    return 0;
}

Description
Alice和Bob在玩耍,突然看见一堆火柴棍和一个n行m列的格子,然后Alice想到要把这些火柴棍放在这些格子中,每个格子火柴棍的数量是随机的。Alice想到一个规则:
1.格子中m一直是偶数
2.每个人能选择任意的一行,且要在这一行选择捡火柴棍的范围[1,m/2],[m/2+1,m]。比如一个人选择[1,m/2]这个范围,他只能从这个范围内一列或多列取走火柴,不能在[m/2+1,m]这范围取火柴棍了
3.每个人取火柴棍的数量必须是大于等于1的
4.谁不能取火柴棍谁就输
5.Alice先手
Input
一共t组数据,t<=101
每组数据n,m(1<=n,m<=100)
然后输入n行m列每个格子火柴棍的数量


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值