Abnormal Termination 为什么通不过ACM测评系统

来源:百度知道 编辑:UC知道 时间:2024/09/21 04:53:39
#include <stdio.h>
#include <math.h>
void main()
{
unsigned long N,M,z,i;
while(scanf("%ld%ld",&N,&M)==2)
{ if(M>10000) return 0;
z=N;
for(i=0;i<9;i++)
{
if(N%M==0)
{ printf("1\n");
break;
}
else
z+=N*pow(10,i+1);
if(z%M==0)
{
printf("%ld\n",i+2);
break;
}
else continue;
}

if(i==9)
printf("0\n");
break;
}
return 0;

}

/*输出没有问题,而且能得到正确的输出*/
/*Find a minimal interger K which is merely comprised of N and can be divided by M.

For example,11 is the minimal number that and be divided by 11, and it is comprised of two '1's, and 111111 can be d

哪里的ACM 地址发来试试
说一下题号
程序有几个错误,改了

#include <stdio.h>
#include <math.h>
int main()
{
unsigned long N,M,z,i;
while(scanf("%ld%ld",&N,&M)==2)
{ if(M>10000) return 0;
z=N;
for(i=0;i<9;i++)
{
if(N%M==0)
{ printf("1\n");
break;
}
else
z+=N*(int)pow(10,i+1);
if(z%M==0)
{
printf("%ld\n",i+2);
break;
}
else continue;
}

if(i==9)
printf("0\n");
break;
}
return 0;

}

i的上限根本不是9,可能会有几千的
z也会因为i太大超整型范围

Abnormal Termination说明你的程序不正常终止.
其实你只要把void main()改成int main(),然后在main函数结尾加一行return 0,也就是让main函数返回一个0就可以了.使用void因为返回值为空,因此当然会提示你不正常终止.