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\n");
        else printf("No\n");
    }
return 0;
}

  

时间: 2024-10-13 11:48:16

Acdream 1115——找规律——Salmon And Cat的相关文章

ACdream原创群赛(13)のwuyiqi退役专场 H Salmon And Cat

H 首先是要姿势正确! 注意完美数的生成机: 2+2a+2b+ab ab都是完美数 假设生成完美数c c = 2 + 2a + 2b + ab c + 2 = ab+2a+2b+4 c + 2 = (a + 2)(b + 2) 然后一开始只有两个完美数1和3. 所以所有的完美数只有质因数分解之后都是类似于 N = (3 ^ x) * (5 ^ y) 但是5不是完美数. 然后就没事了... /**** *COPYRIGHT NOTICE *Copyright (c) 2014 *All right

Acdream 1210 Chinese Girls&#39; Amusement(大数模板运算 + 找规律)

传送门 Chinese Girls' Amusement Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description You must have heard that the Chinese culture is quite different from that of Europe or Rus

ACdream 1213 Matrix Multiplication【水题 、 找规律】

Matrix Multiplication Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) 链接:http://acdream.info/problem?pid=1213 Problem Description Let us consider undirected graph G = {V; E} which has N vertices and M edges. Incidence

acdream 1210 Chinese Girls&#39; Amusement (打表找规律)

题意:有n个女孩围成一个圈从第1号女孩开始有一个球,可以往编号大的抛去(像传绣球一样绕着环来传),每次必须抛给左边第k个人,比如1号会抛给1+k号女孩.给出女孩的人数,如果他们都每个人都想要碰到球一次,那么这个k应该是多少(满足 1 ≤ K ≤ N/2 且 k必须尽量大)?   例如:n=7,那么1号开始拿球,抛球的顺序是 1, 4, 7, 3, 6, 2, 5, 1.  当球重新回到1女孩手中时,每个人刚好只玩了一次.注:这个数字相当大(3 ≤ N ≤ 102000) 思路: 方法(1): 暴

Acdream 1416 Crazy Nim(简单博弈找规律)

传送门 Crazy Nim Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description Alice and Bob like to play crazy nim. The game proceeds as follows. There are several stones arranged in

The Cow Lineup_找规律

Description Farmer John's N cows (1 <= N <= 100,000) are lined up in a row.Each cow is labeled with a number in the range 1...K (1 <= K <=10,000) identifying her breed. For example, a line of 14 cows might have these breeds: 1 5 3 2 5 1 3 4 4

UVA - 1646 - Edge Case(找规律)

题意:n(3 <= n <= 10000)个结点组成一个圈,求匹配(即没有公共点的边集)的个数. 找规律为斐波那契的性质,因为数太大所以用的java大数. import java.math.BigInteger; import java.util.Scanner; public class Main{ public static int MAXN = 10000 + 10; public static BigInteger []c = new BigInteger[MAXN]; public

【55测试】【字符串】【栈】【找规律】

集训第二天,额,考崩了. 第一题 hao 大意:(这个名字就不要在意了,其实是祖玛游戏) 模拟祖玛游戏的模式,给一个'A'~'Z'的字符串,然后有t个插入操作为 “ 添加后的在原字符串的位置 x  插入元素 c ”,字符串中有超过或等于 3 个相同的字符,则被消除,输出每次操作后剩余的字符串,如果为空,则输出“-”. 样例: ACCBA                     输出:  ABCCBA 5   AABCCBA 1 B AABBCCBA 0 A - 2 B A 4 C 0 A 解:

2016(胡赛复现)_大数找规律

Time Limit: 5 Sec  Memory Limit: 128 MB Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) 的数量: 1. 1≤a≤n,1≤b≤m;  2. a×b 是 2016 的倍数. Input 输入包含不超过 30 组数据. 每组数据包含两个整数 n,m (1≤n,m≤109). Output 对于每组数据,输出一个整数表示满足条件的数量. Sample Input 32 63 2016 2016 1000000000 1000