zoukankan      html  css  js  c++  java
  • HDU_1999——不可摸数

    Problem Description
    s(n)是正整数n的真因子之和,即小于n且整除n的因子和.例如s(12)=1+2+3+4+6=16.如果任何
    数m,s(m)都不等于n,则称n为不可摸数.
     
    Input
    包含多组数据,首先输入T,表示有T组数据.每组数据1行给出n(2<=n<=1000)是整数。
     
    Output
    如果n是不可摸数,输出yes,否则输出no
     
    Sample Input
    3 2 5 8
     
    Sample Output
    yes yes no
     1 #include <cstdio>
     2 #include <cmath>
     3 int mark[1001]={0};
     4 void fun(void)
     5 {
     6    mark[1]=1;
     7    for(int n=4;n<1000000;n++)
     8       {
     9          int s=1;
    10          int o=(int)sqrt(double(n));
    11          for(int j=2;j<=o;j++)
    12             if(n%j==0)
    13                {
    14                   if(j*j==n)
    15                      s=s+j;
    16                   else
    17                      s=s+j+n/j;
    18                   if(s>1000)  break;   
    19                }
    20          if(s<1001)
    21             mark[s]=1;
    22       }  
    23 }
    24 
    25 int main()
    26 {
    27    int T,n;
    28    scanf("%d",&T);
    29    fun();
    30    while(T--)
    31       {
    32          scanf("%d",&n);
    33          if(mark[n])
    34             printf("no\n");
    35          else
    36             printf("yes\n");   
    37       }
    38    return 0;   
    39 }
    ——现在的努力是为了小时候吹过的牛B!!
  • 相关阅读:
    交叉排序
    交叉排序
    数据结构实验之串三:KMP应用
    数据结构实验之串三:KMP应用
    数据结构实验之串一:KMP简单应用
    数据结构实验之串一:KMP简单应用
    走迷宫
    走迷宫
    走迷宫
    走迷宫
  • 原文地址:https://www.cnblogs.com/pingge/p/3137982.html
Copyright © 2011-2022 走看看