首页 > 代码库 > ACdream原创群赛(13)のwuyiqi退役专场 H 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 rights reserved
    
	*@author    Shen
	*@name		H
	*@file		G:\My Source Code\比赛与日常练习\0608 - wuyiqi退役赛\H\H.cpp
	*@date		2014/6/8 18:30
	*/

//#pragma GCC optimize ("O2")
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;

/*//STL
#include <map>
#include <vector>
#include <list>
#include <stack>
#include <deque>
#include <queue>
*/

/*//Computational Geometry
#include <complex>
#define x real()
#define y imag()
typedef complex<double> point;
*/

typedef long long int64;
int a, b, n;

void solve()
{
	a = 0, b = 0, n += 2;
	while (n % 3 == 0) a++, n /= 3;
	while (n % 5 == 0) b++, n /= 5;
	if (n == 1) puts("Yes");
	else puts("No");
	return;
}

int main()
{
	while (~scanf("%d", &n)) solve();
	return 0;
}