• 威佐夫博弈


    学习:https://blog.csdn.net/angle555945/article/details/7417722

    题目链接:https://vjudge.net/contest/231317#status/1751151850/E/0/

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

    直接看代码吧,我也说不清思路
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<stdio.h>
    #include<string.h>
    #include<cmath>
    #include<math.h>
    #include<algorithm>
    #include<set>
    #include<queue>
    typedef long long ll;
    using namespace std;
    const ll mod=1e9+7;
    const int maxn=1e5+10;
    const ll maxa=32050;
    const double x=(1.0+sqrt(5.0))/2;//注意sqrt只能用与double 和float类型的数,不能用于整形,否则要强制性类型转化
    #define INF 0x3f3f3f3f3f3f
    int main()
    {
        ll a,b;
        while(cin>>a>>b)
        {
            if(a>b)
                swap(a,b);
            int k=b-a;
            if(a==(int)(k*x))
                cout<<"0"<<endl;
            else
                cout<<"1"<<endl;
        }
        return 0;
    }
    当初的梦想实现了吗,事到如今只好放弃吗~
  • 相关阅读:
    使用 OpCache 提升 PHP 性能
    在线视频开发博客教程
    修正ECMALL在PHP5.3以上版本中无法开启支付方式的BUG
    第二个小项目的讲解后感言
    mybatis进行分页,使用limit
    mybatis传递多个参数值(转)
    一个关于前端页面的小标签<tbody>
    json-lib的一些过滤操作
    关键字volidate和transient(转)
    Java中实现序列化的两种方式 Serializable 接口和 Externalizable接口
  • 原文地址:https://www.cnblogs.com/caijiaming/p/9336273.html
Copyright © 2020-2023  润新知