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 |
请高手指点,那儿错了?#include<stdio.h> #define MAX 1000000 int num[102]; char ch[105]; long K,test; int tag; int prime[MAX]={1,1,0}; void Prime() { long i, j; for (i=2; i<=MAX; i++) if (prime[i] == 0) for (j=2*i; j<=MAX; j+=i) prime[j] = 1; } int zhengchu() { long temp; int i; temp=0; for(i=0;i<tag;i++) { temp=temp*10+num[i]; temp%=test; } if(temp==0) return 1; return 0; } int main() { int i; Prime(); scanf("%s%ld",ch,&K); while(ch[0]&&K) { int flag=0; for(i=0;ch[i]>='0';i++) num[i]=ch[i]-'0'; tag=i; for(test=2;test<K;test++) if((!prime[test])&&zhengchu()) { flag=1; printf("BAD %ld\n",test); break; } if(!flag) printf("GOOD\n"); scanf("%s%ld",ch,&K); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator