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 |
急求测试数据!怎么老WA,高手帮忙!#include<stdlib.h> #include<math.h> #include<iostream> using namespace std; int main() { long n; cin>>n; while(n>=0) { if(n==0){ cout<<"0 coconuts, no solution"<<endl; cin>>n; continue; } else{ long x=2,people=0; for(x=2;x<=9;x++) { long n1=n+x-1; long pow_x=(long)pow((double)x,x); if(n1<pow_x) { break; }else if((n1%pow_x)==0) { n1=(long)(n1/pow_x); long pow_x_1=(long)pow((double)(x-1),x); n1=(long)(n1*pow_x_1+1); if((n1%x)==0 && (n1/x)>=2) people=x; } } if(people!=0) cout<<n<<" coconuts, "<<people<<" people and 1 monkey"<<endl; else cout<<n<<" coconuts, no solution"<<endl; cin>>n; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator