zoukankan      html  css  js  c++  java
  • 2015ACM/ICPC亚洲区沈阳站-重现赛 1004 Pagodas

    Problem Description:
    n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two of them (labelled aand b, where 1abn) withstood the test of time.

    Two monks, Yuwgna and Iaka, decide to make glories great again. They take turns to build pagodas and Yuwgna takes first. For each turn, one can rebuild a new pagodas labelled i (i{a,b} and 1in) if there exist two pagodas standing erect, labelled j and k respectively, such that i=j+k or i=jk. Each pagoda can not be rebuilt twice.

    This is a game for them. The monk who can not rebuild a new pagoda will lose the game.
     
    Input:
    The first line contains an integer t (1t500) which is the number of test cases.
    For each test case, the first line provides the positive integer n (2n20000) and two different integers a and b.
     
    Output:
    For each test case, output the winner (``Yuwgna" or ``Iaka"). Both of them will make the best possible decision each time.
     
    Sample Input:
    16
    2 1 2
    3 1 3
    67 1 2
    100 1 2
    8 6 8
    9 6 8
    10 6 8
    11 6 8
    12 6 8
    13 6 8
    14 6 8
    15 6 8
    16 6 8
    1314 6 8
    1994 1 13
    1994 7 12
     
    Sample Output:
    Case #1: Iaka
    Case #2: Yuwgna
    Case #3: Yuwgna
    Case #4: Iaka
    Case #5: Iaka
    Case #6: Iaka
    Case #7: Yuwgna
    Case #8: Yuwgna
    Case #9: Iaka
    Case #10: Iaka
    Case #11: Yuwgna
    Case #12: Yuwgna
    Case #13: Iaka
    Case #14: Yuwgna
    Case #15: Iaka
    Case #16: Iaka

    题意:给出n,a,b,现在问你在已有的数字基础之上建立a-b或者a+b的数(这个数不能已经存在(已经存在的的数是a和b),而且必须在1~n之间),Yuwgna先建立,Iaka后建立,那么最终谁不能建立就输了,输出赢的人。。。。。Alice  and  Bob来袭,吼吼。

    举例:14  6  13  那么可以建立的数有:7, 1, 5, 4, 3, 2, 8, 9, 10, 11, 12, 14,所以到Yuwgna就建不成了,Iaka赢。。。。。可以发现a和b的最大公约数就是建立的数之间的间隔,那么总共是n,间隔是最大公约数,可以建立的个数就是总数/间隔了,,,,(发现因子含有最大公约数的数都可以被建立(1~n之间的数))。

    #include<stdio.h>
    #include<string.h>
    #include<queue>
    #include<math.h>
    #include<stdlib.h>
    #include<algorithm>
    using namespace std;
    
    const int N=1e2+10;
    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    
    typedef long long LL;
    
    int Gcd(int a, int b)
    {
        return b == 0 ? a : Gcd(b, a%b);
    }
    
    int main ()
    {
        int T, n, a, b, c, k = 0;
    
        scanf("%d", &T);
    
        while (T--)
        {
            k++;
    
            scanf("%d%d%d", &n, &a, &b);
    
            c = Gcd(a, b);
    
            n /= c;
    
            if (n % 2 == 0) printf("Case #%d: Iaka
    ", k);
            else printf("Case #%d: Yuwgna
    ", k);
        }
    
        return 0;
    }
  • 相关阅读:
    QT4.7.1 + VS2008 + QT Designer开发流程心得
    SharePoint 2010 托管元数据Bug (跟邮件提醒功能相关.小bug,大问题)
    SharePoint 2010 技巧系列: 控制Ribbon菜单权限(SiteActions的例子)
    发布一个SharePoint 2010 工具(复制,移动文件和文件夹)
    SHarePoint 2010 技巧 列验证 (column Validation)
    SharePoint 2010系列: 教你如何创建Internet 站点一 (设计母版页)
    SharePoint2010 技巧系列:快速开发Ribbon
    SharePoint 2010 技巧: 限制People Picker搜索非站点集内的用户
    SharePoint 2010 技巧系列 启用文档库接收邮件功能
    SharePoint 2010 技巧系列: 文档管理的自动分发功能
  • 原文地址:https://www.cnblogs.com/syhandll/p/4926262.html
Copyright © 2011-2022 走看看