zoukankan      html  css  js  c++  java
  • HDU 2104 hide handkerchief

    题解:由题目可以知道,如果n和m的最大公约数不为1,那么总有箱子是无法遍历的,所以求一遍GCD就可以判断了。

    注意点:一定要记住判断是==,在做题时又忘了。

    #include <cstdio>
    int gcd(int a,int b)
    {
        if (b==0) return(a);
        else return(gcd(b,(a%b)));
    }
    
    int main()
    {
        int n,m;
        while(scanf("%d%d",&n,&m),n!=-1||m!=-1)
        {
            if (gcd(m,n)==1)
            puts("YES");
            else puts("POOR Haha");
        }
        return 0;
    }
  • 相关阅读:
    CodeForces
    HDU
    HDU
    POJ
    URAL
    POJ
    UVa
    UVa
    UVa
    UVa
  • 原文地址:https://www.cnblogs.com/forever97/p/3483903.html
Copyright © 2011-2022 走看看