题目链接:传送门

题意:

一个数被觉得是一个完美的数,仅仅要须要满足下面的两个条件之中的一个

1)x = 1 or 3

2)x = 2 + a*b + 2*a + 2*b; a。b都是完美的数。

分析:

x + 2 = (a + 2)*(b + 2)

因为x1=1,x2=3。全部的数都是由着两个数衍生而来。那么我们就可

以得出一个结论了。一个数x假设是完美的数。那么x = 3^p*5^q;

因此代码例如以下:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <set>
#include <map>
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) puts("No");
else puts("Yes");
}
return 0;
}

还能够打表把1e9以内的全部完美数打出来。

代码例如以下:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <set>
#include <map>
using namespace std; typedef long long LL; LL a[140]={1,3,7,13,23,25,43,73,79,123,133,223,241,373,403,623,673,727,1123,1213,1873,2023,2185,3123,3373,3643,5623,6073,6559,9373,10123,10933,15623,16873,18223,19681,28123,30373,32803,46873,50623,54673,59047,78123,84373,91123,98413,140623,151873,164023,177145,234373,253123,273373,295243,390623,421873,455623,492073,531439,703123,759373,820123,885733,1171873,1265623,1366873,1476223,1594321,1953123,2109373,2278123,2460373,2657203,3515623,3796873,4100623,4428673,4782967,5859373,6328123,6834373,7381123,7971613,9765623,10546873,11390623,12301873,13286023,14348905,17578123,18984373,20503123,22143373,23914843,29296873,31640623,34171873,36905623,39858073,43046719,48828123,52734373,56953123,61509373,66430123,71744533,87890623,94921873,102515623,110716873,119574223,129140161,146484373,158203123,170859373,184528123,199290373,215233603,244140623,263671873,284765623,307546873,332150623,358722673,387420487,439453123,474609373,512578123,553584373,597871123,645700813,732421873,791015623,854296873,922640623,996451873,
}; int main(){
int n;
while(~scanf("%d",&n)){
int ans = 0;
for(int i=0;i<137;i++)
if(a[i]==n) ans = 1;
if(ans) puts("Yes");
else puts("No");
}
return 0;
}

ACdream 1115 Salmon And Cat (找规律&amp;&amp;打表)的更多相关文章

  1. Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目

    D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  2. luogu1775 古代人的难题 打表找规律

    题目大意:给出一正整数k,求满足(x^2-x*y-y^2)^2=1且x,y∈[1,k]且x^2+y^2最大的正整数x,y. 既然x,y的范围给出来了,我们便有了暴力解法.因此,本题最适合打表找规律了! ...

  3. 计蒜客 39279.Swap-打表找规律 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest L.) 2019ICPC西安邀请赛现场赛重现赛

    Swap There is a sequence of numbers of length nn, and each number in the sequence is different. Ther ...

  4. hdu 3951 - Coin Game(找规律)

    这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...

  5. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

  6. hdu4952 Number Transformation (找规律)

    2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...

  7. CF456B Fedya and Maths 找规律

    http://codeforces.com/contest/456/problem/B CF#260 div2 B Fedya and Maths Codeforces Round #260 B. F ...

  8. hdu 4731 2013成都赛区网络赛 找规律

    题意:找字串中最长回文串的最小值的串 m=2的时候暴力打表找规律,打表可以用二进制枚举

  9. 找规律 Codeforces Round #290 (Div. 2) A. Fox And Snake

    题目传送门 /* 水题 找规律输出 */ #include <cstdio> #include <iostream> #include <cstring> #inc ...

随机推荐

  1. Win7安装IDL8.0以及破解

    参考:http://bbs.06climate.com/forum.php?mod=viewthread&tid=5230 1.下载IDL8.1和证书 下载地址:http://yunpan.c ...

  2. Oracle VirtualBox 模拟Android系统 素材

    Android to x86 下载地址: http://www.android-x86.org/download VirtualBox 下载地址: https://www.virtualbox.org ...

  3. 单独删除std::vector <std::vector<string> > 的所有元素

    下面为测试代码: 1.创建 std::vector< std::vector<string> > vc2; 2.初始化 std::vector<string> vc ...

  4. 黑马程序员——Block数据类型

    Block数据类型,又被称为代码段.因为它可以封装一段代码.苹果官方建议多用block.因为在多线程控制.异步任务,集合遍历.集合排序.动画转场等方面用的很多. Block的特点: 1.Block 用 ...

  5. 数字图像去噪典型算法及matlab实现

    原文地址http://jncumter.blog.51cto.com/812546/243961   图像去噪是数字图像处理中的重要环节和步骤.去噪效果的好坏直接影响到后续的图像处理工作如图像分割.边 ...

  6. Windows平台分布式架构-负载均衡(高并发)

    缘由 单纯想在winodows平台部署分布式程序,微软在IIS扩展的介绍中有涉及到Application Request Router + Web Farm + Url Rewriter可以实现分布式 ...

  7. js运动 多物体运动含Json 但是里面数值不一样

    <!doctype html> <html> <head> <meta charset = "utf-8"> <title&g ...

  8. QueryInterface

    QueryInterface IUnknown *p2; hr = pInnerUnknown->QueryInterface(vGUID2, (void**)&p2); IUnknow ...

  9. vs2012 密匙

    旗舰版 YKCW6-BPFPF-BT8C9-7DCTH-QXGWC

  10. MecAnim

    [MecAnim] MecAnim是Unity 4.0推出的新的动画系统,新系统使用Animator组件来控制动画,老系统使用Animation组件来控制动画.此篇讲述MecAnim系统. What ...