oj过不了,提示Presentation Error,请帮我修改代码,使之能过oj。
题目链接:HDU2010 https://acm.hdu.edu.cn/showproblem.php?pid=2010
我的代码:
#include <stdio.h>
int res[10]={0};
int main()
{
int a,b,c,m,n,s=0;
int x=0;
int n1=0,n2=0;
for (a=1;a<=9;++a)
{
for (b=0;b<=9;++b)
{
for (c=0;c<=9;++c)
{
n=a*100+b*10+c;
m=a*a*a+b*b*b+c*c*c;
if (m==n)
{
res[s]=n;
++s;
}
}
}
}
while (scanf("%d %d",&n1,&n2)!=EOF)
{
x=0;
for (int i=0;i<s-1;++i) if (res[i]>=n1&&res[i]<=n2)
{
printf("%d ",res[i]);
++x;
}
if (res[s-1]>=n1&&res[s-1]<=n2)
{
printf("%d",res[s-1]);
++x;
}
if (x==0) printf("no");
}
return 0;
}