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;
    }
  • 相关阅读:
    Ubuntu apt-get "Hash Sum mismatch" 问题解决方法
    模型压缩相关工作
    bn两个参数的计算以及layer norm、instance norm、group norm
    cascade rcnn论文总结
    c++ 堆和栈以及区别
    c++ 浅拷贝和深拷贝 指针和引用的区别 malloc(free)和new(delete)的区别 重载重写重定义
    c++ 多态,虚函数、重载函数、模版函数
    c++问题整理
    repulsion-loss
    smooth l1
  • 原文地址:https://www.cnblogs.com/syhandll/p/4926262.html
Copyright © 2011-2022 走看看