杭电1999题,测试数据都过了,为什么Wrong Answer,请那位大牛帮忙改改,谢谢!! !
不可摸数TimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmi...
不可摸数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3719 Accepted Submission(s): 976
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
Author
Zhousc@ECJTU
Source
ECJTU 2008 Spring Contest
Recommend
代码是
#include<stdio.h>
main()
{
int ri,repeat,i,j,n,d,s;
scanf("%d",&repeat);
for(ri=1;ri<=repeat;ri++)
{
scanf("%d",&n);
d=0;
for(i=2;i<2*n;i++)
{
s=0;
for(j=1;j<=i/2;j++)
{ if(i%j==0)
s=s+j; }
if(s==n)
d=1;
}
if(d==1)
printf("no\n");
else
printf("yes\n");
}
} 展开
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3719 Accepted Submission(s): 976
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
Author
Zhousc@ECJTU
Source
ECJTU 2008 Spring Contest
Recommend
代码是
#include<stdio.h>
main()
{
int ri,repeat,i,j,n,d,s;
scanf("%d",&repeat);
for(ri=1;ri<=repeat;ri++)
{
scanf("%d",&n);
d=0;
for(i=2;i<2*n;i++)
{
s=0;
for(j=1;j<=i/2;j++)
{ if(i%j==0)
s=s+j; }
if(s==n)
d=1;
}
if(d==1)
printf("no\n");
else
printf("yes\n");
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询