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 |
Re:任何数据我都测试过了.为什么还是不行呢?这道题真闹心.In Reply To:任何数据我都测试过了.为什么还是不行呢?这道题真闹心. Posted by:kkmmnn at 2006-10-02 17:12:18 终于AC了.步长应该用最小的. #include<iostream> using namespace std; int main() { int p,e,i,d,x,n,s; cin>>p>>e>>i>>d; n=1; while(!(p==-1&&e==-1&&i==-1&&d==-1)) { s=p; if(s>e) s=e; if(s>i) s=i; if(s>d) s=d; p=p-s; e=e-s; i=i-s; d=d-s; if(p==0&&e==0&&i==0) x=21252-d; else { x=p; if (p==0) x=+23; while(!((x-e)%28==0&&(x-i)%33==0)) x+=23; x=x-d; } if(x>21252) x=x-21252; if(x<0) x=x+21252 ; cout<<"Case "<<n<<": the next triple peak occurs in "<<x<<" days."<<endl; n++; cin>>p>>e>>i>>d; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator