题目链接:传送门

题意:

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

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. AngularJs学习教程

    AngularJs 目录 AngularJs实战一 购物车 细讲ng-repeat指令 ng-show和ng-hide ng-class指令 ng-src和ng-href 应用控制器中的职责 watc ...

  2. python字典概述

    字典 1.    概述 字典是一个无序的数据集合,序列类型用有序的数字键做索引将数据以数组的形式存储. 在字典中能获得的有序集合只能是键的集合或者是值得集合,方法keys()或者value()返回一个 ...

  3. mysql error: Access denied for user 'root'@'localhost' (using password: YES)

    昨天重装了下系统,安装好mysql后,安装了客户端工具连接mysql,提示Access denied for user 'root'@'localhost' (using password: YES) ...

  4. 【整理】JavaEE基本框架(Struts2+Spring+MyBatis三层,Struts MVC)之间的关系

    #[整理]JavaEE基本框架(Struts2+Spring+MyBatis三层,Struts MVC)之间的关系 ![关系图解](http://images.cnitblog.com/blog/84 ...

  5. Ubuntu14.04下安装QQ 国际版

    在/etc/apt/source.list文件中添加: deb http://packages.linuxdeepin.com/deepin trusty main non-free universe ...

  6. hadoop-1.2.0源码编译

    以下为在CentOS-6.4下hadoop-1.2.0源码编译步骤. 1. 安装并且配置ant 下载ant,将ant目录下的bin文件夹加入到PATH变量中. 2. 安装git,安装autoconf, ...

  7. HDU1243:反恐训练营

    题目链接:反恐训练营 题意:本质上是求最大公共子序列,然后加上一个权值 分析:见代码 //公共子序列问题 //dp[i][j]表示前s1的前i个与s的前j个匹配得到的最大公共子序列 #include& ...

  8. Hadoop 1.1.2 Eclipse 插件使用——异常解决

    permission denied user 1.修改配置文件在conf/hdfs-site.xml文件中添加如下内容: <property> <name>dfs.permis ...

  9. Django中如何使用django-celery完成异步任务1(转)

    原文链接: http://www.weiguda.com/blog/73/ 本篇博文主要介绍在开发环境中的celery使用,请勿用于部署服务器. 许多Django应用需要执行异步任务, 以便不耽误ht ...

  10. 关于缺省路由传递问题的探讨(下)[ip default-network、ip default-gateway等]

    之前文章介绍的是没有路由协议的环境下,那么在有路由协议的环境下: ip default-network IGRP/EIGRP: IP Default-Network所指定的网络必须在EIGRP进程中通 ...