|
|
back to boardRe: Test #8 Posted by Andres 3 Oct 2010 02:25 Yep... problem in java was using int instead of long. Re: Test #8 Posted by VityaZ 5 Oct 2010 15:11 I have Q->555555555888 when N=1 000 000 000, but Test#8 say "WA". Why? Re: Test #8 Edited by author 02.10.2011 20:48 Re: Test #8 use long long int Re: Try this~! my solution in c++ 0.031 s. #include<iostream> #include<cmath> #include<string> #include<algorithm> using namespace std; inline bool isprime(long a) { if(a==1)return false; if(a==2)return true; if(a%2==0)return false; for(int i=3;i<sqrt(a);i+=2) { if(a%i==0)return false; } return true; } int main() { string a; long n; int d=1; cin>>n; if(n==0)cout<<"10"<<endl; else if(n==1)cout<<"1"<<endl; else{ if(isprime(n) && n>10)d=0; else { int gamyop=9; while(n!=1) { if(n%gamyop==0) { a+=(gamyop+'0'); n/=gamyop; if(isprime(n) && n>10){d=0;break;} } else { gamyop--; } } } sort(a.begin(),a.end()); if(d==1)cout<<a<<endl; else cout<<"-1"<<endl; } return 0; } I have this problem too!!! All test, what i see is correct; I use unsigned long; May be it consist false; What I doing wrong? Edited by author 05.04.2006 14:23 Re: Test #8 enlarge your array size Re: Test #8 thanks mate. I was getting wrong for this reason. Those who are getting WA at Test #8. try to use "Unsigned long long int" insted of "int". |
|
|