zoukankan      html  css  js  c++  java
  • Acdream 1115——找规律——Salmon And Cat

    Math is very important, for those who are also in school, make sure you will learn more about math.

    Salmon and Cat are good friends.Today Salmon ask Cat to help her judge whether a number is perfect or not. Perfect number is a kind of number defined by like this.

    First, 1 and 3 are perfect number.Then if a and b are perfect numbers, 2+ab+2a+2b is also a perfect number.For example, 1 and 1 are perfect numbers,  so 2+1+2+2 = 7 is perfect number.

    If Cat can't help Salmon,  Salmon will be sad and Cat will be much more sad. So Cat must solve the problem to maintain their friendship. Can you help Cat to solve the problem?

    Input

    This problem contains multiple test cases.

    Each test case contains one line.

    Each line contains an interger n, 1 ≤ n ≤ 109.

    Output

    For each test case, if n is a perfect number, output “Yes”, otherwise output “No”.

    Sample Input

    3
    7
    8
    

    Sample Output

    Yes
    Yes
    No
    

    Hint

    /*
       找规律..
       所有数都是3或5之积
    */
    #include<cstdio>
    #include<cstring>
    using namespace std;
    
    int main()
    {
        int n;
        while(~scanf("%d", &n)){
            n += 2;
            while(n % 3 == 0) n/= 3;
            while(n % 5 == 0) n/= 5;
            if(n == 1) printf("Yes
    ");
            else printf("No
    ");
        }
    return 0;
    }
                
    

      

  • 相关阅读:
    python2和python3中TestSuite().addTest的区别
    python2和python3中range的区别
    WebDriverAgent安装
    Charles IOS https抓包
    Python和 pytest的异常处理
    Python中yaml和json文件的读取和应用
    Python 获取当前文件所在路径
    自建包函数调用
    python的logging,将log保存到文件
    泛型
  • 原文地址:https://www.cnblogs.com/zero-begin/p/4649587.html
Copyright © 2011-2022 走看看