|
|
back to boardWHY WRONG ANSWER HELP ME! Posted by TRTR 4 Apr 2007 22:00 #include <iostream.h> #include <math.h> int prost(int a) { int kol=0; for(int i=2;i<=int (sqrt(a));i++) { if(a%i==0) kol++; } if(kol==0) return 1; else return 0; } int main() { int T,n,kol=0,i=0,p=2; cin>>T; for(int j=0;j<T;j++) { cin>>n; while(i!=n) { if((prost(pow(2,p)-1))==1) { i++; } if(i==n) { cout<<p<<' '; } p++; }
} return 0; } Re: WHY WRONG ANSWER HELP ME! All Mersenne primes you can find in text of problem... Good luck!.. Why didn't you try sample test? (-) |
|
|