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 |
why did I got WA?(code attached)#include<iostream> #include<math.h> using namespace std; const double e = 0.69314718055994530941723212145818; int main() { double n; int s,i,temp; while(1){ cin >> n; if(!n) break; if(n > 0) { if(n==1) { cout << 1 << endl; break; } s = log(n)/e; for(i = s;i > 0;i --) { temp = (int)pow(n,1/(double)i); if(pow((double)temp,(double)i) == n) { cout << i << endl; break; } } } else { n = -n; s = log(n)/e; for(i = s;i > 0;i --) if(i % 2) { temp = (int)pow(n,1/(double)i); if(pow((double)temp,(double)i) == n) { cout << i << endl; break; } } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator