Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Runtime Error!!! Why?? For help!!#include <stdio.h> #include <memory.h> #include <string.h> int primelist[500000]; bool isnotprime[1000005]; void Sai() { int i,j,num; memset(isnotprime,0,sizeof(isnotprime)); isnotprime[0] = isnotprime[1] = 1; num = 0; for(i = 2;i <= 1000000;i++) { if(!isnotprime[i]) { primelist[num++] = i; if(1LL * i * i > 1LL * 1000000) continue; for(j =1LL * i * i;j <= 1000000;j += i) isnotprime[j] = 1; } } //for(i = 0;i < ;i++) //printf("%d %d\n%lld",primelist[num-2],primelist[num-1],(long long)primelist[num-2]*primelist[num-1]); } int main() { int i,j,length,k,s,t,x; char a[105]; int arr[50]; Sai(); while(1) { scanf("%s %d",a,&t); if(t == 0) break; length = strlen(a);//printf("%d\n",length); for(i = 1;i <= 3;i++) if((length - i) % 3 == 0) break; memset(arr,0,sizeof(arr)); for(j = 0;j < i;j++) arr[0] = arr[0] * 10 + (a[j] - '0'); k = 0;x = 0; for(j = i;j < length;j++) { k++; if(k % 3 == 1) x++; arr[x] = arr[x] * 10 + (a[j] - '0'); } s = 1; for(i = 0;primelist[i] < t;i++) { s = 0; for(j = 0;j <= x;j++) s = (s * 1000 + arr[j]) % primelist[i]; if(s == 0) break; } if(s == 0) printf("BAD %d\n",primelist[i]); else printf("GOOD\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator