|
|
back to boardThis problem is quite strange!!! This problem is so strange. First is the word"?"should be"-1",otherwise you'll get WA. Second,I have submitted 5 times the same programme(following), but alternatively got "Crash(Access Violation)" and "Accepted". Who knows why? int factor[60]; int p=0; int main() { int i; long n; scanf("%ld",&n); if(n==0)printf("10"); if(n==1)printf("1"); if(n>=2) { while(1) { for(i=9;i>=2;i--)if(n%i==0)break; if(i>1) { n=n/i; p++; factor[p]=i; continue; } else break; } if(n>=10)printf("-1"); else { for(i=p;i>=1;i--) { printf("%d",factor[i]); } } } return(0); } Re: This problem is quite strange!!! > This problem is so strange. > First is the word"?"should be"-1",otherwise you'll get WA. > > Second,I have submitted 5 times the same programme(following), > but alternatively got "Crash(Access Violation)" and "Accepted". > Who knows why? > > > > int factor[60]; > int p=0; > > int main() > { > int i; > long n; > scanf("%ld",&n); > if(n==0)printf("10"); > if(n==1)printf("1"); > if(n>=2) > { > while(1) > { > for(i=9;i>=2;i--)if(n%i==0)break; > if(i>1) > { > n=n/i; > p++; > factor[p]=i; > continue; > } > else break; > } > if(n>=10)printf("-1"); > else > { > for(i=p;i>=1;i--) > { > printf("%d",factor[i]); > } > } > } > return(0); > } My god ,I had got many WA ,because I'd printed ?. faint! |
|
|