zoukankan      html  css  js  c++  java
  • ACdream 1115 Salmon And Cat (找规律&&打表)

    题目链接:传送门

    题意:

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

    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;
    }
    
    


     

  • 相关阅读:
    实验一 网络侦查与网络扫描
    网络对抗作业一
    [BSidesCF 2020]Hurdles
    [BSidesCF 2019]Mixer
    安恒期末 admin
    C#编程:正则表达式验证身份证校验码-10
    分享1-3年经验的Java面试
    SpringMVC配置web.xml文件详解(列举常用的配置)
    Hibernate全套增删改查+分页
    Node.js连接mysql数据库方法
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5369724.html
Copyright © 2011-2022 走看看