题目链接:传送门

题意:

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

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. VBS学习:流程控制语句判断结构

    一.数值运算: 1) Dim a,b,c a=inputbox("a是:","输入半径") b=Inputbox("b是:","输 ...

  2. CAT XQX ---- 增删改查架构说明 1

    View 层  --  以国家为例 1. 显示 数据库的 table 页面效果 对应代码: <table id="dg" title="国家信息" cla ...

  3. DTD 简介

    文档类型定义(DTD)可定义合法的XML文档构建模块.它使用一系列合法的元素来定义文档的结构.DTD 可被成行地声明于 XML 文档中,也可作为一个外部引用. 内部的 DOCTYPE 声明 假如 DT ...

  4. C# 类和结构

    类和结构实际上都是创建对象的模板,每个对象都包含数据,并提供了处理和访问数据的方法 . 类定义了类的每个对象(称为实例)可以包含什么数据和功能. 例如,如 果一个类表示一个顾客,就可以定义字段 Cus ...

  5. 在Jenkins中使用Git Plugin访问Https代码库失败的问题

    最近需要在Jenkins上配置一个Job,SCM源是http://git.opendaylight.org/gerrit/p/integration.git 于是使用Jenkins的Git Plugi ...

  6. Epic - Spiral Matrix

    Given aNXN matrix, starting from the upper right corner of the matrix start printingvalues in a coun ...

  7. 【C#】Abstract和Virtual的区别

    一.Virtual方法(虚方法) virtual 关键字用于在基类中修饰方法.virtual的使用会有两种情况: 情况1:在基类中定义了virtual方法,但在派生类中没有重写该虚方法.那么在对派生类 ...

  8. 整理string类常见方法的使用说明

    整理String类的Length().charAt().getChars().replace().toUpperCase().toLowerCase().trim().toCharArray()使用说 ...

  9. 判断浏览器是IE的几种方式

    <script> if(!+[1,])alert("这是ie浏览器"); else alert("这不是ie浏览器"); </script&g ...

  10. SpringMVC + Spring + MyBatis 学习笔记:提交数据遭遇基础类型和日期类型报400错误解决方法

    系统:WIN8.1 数据库:Oracle 11GR2 开发工具:MyEclipse 8.6 框架:Spring3.2.9.SpringMVC3.2.9.MyBatis3.2.8 使用SpringMVC ...