zoukankan      html  css  js  c++  java
  • HDU1527

    有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。

    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

    思路:模板题,没有什么好说的QAQ

    #include <iostream>
    #include <cstdio>
    #include <vector>
    #include <cstring>
    #include <algorithm>
    #include <string>
    #include <queue>
    #include<cmath>
    using namespace std;
    //const int N=100005;
    //const int INF=0x3f3f3f3f;
    int main()
    {
        int a,b,k;
        double c;
        while(scanf("%d%d",&a,&b)!=EOF)
        {
            if(a>b)
                swap(a,b);
            k=b-a;
            c=(1.0+sqrt(5.0))/2.0;
            if(a==int(c*k))
                printf("0
    ");
            else
                printf("1
    ");
        }
        return 0;
    }
  • 相关阅读:
    mybatis和spring整合
    Freemarker教程1(基本使用)
    mybatis教程6(逆向工程)
    mybatis教程4(动态SQL)
    mybatis教程5(延迟加载和缓存)
    mybatis教程2(配置文件)
    python作用域
    软件测试基础面试题
    http协议
    selenium自动化测试
  • 原文地址:https://www.cnblogs.com/aerer/p/9930995.html
Copyright © 2011-2022 走看看