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 wrong answer?//每次找三个数中最小的一个,然后加上相应有23 28 33,直到三个数相等 //判断如果这三个数比第四个数小或大两种情况, #include <iostream> using namespace std; int main() { int a[4]; int k,i,p; int min; k=0; while(1){ cin>>a[0]>>a[1]>>a[2]>>a[3]; if(a[0]==-1 && a[1]==-1 && a[2]==-1 && a[3]==-1) break; while(a[0]!=a[1] || a[1]!=a[2] ) { min=32767; for(i=0;i<3;i++){ if(a[i]<min) { min=a[i]; p=i; } } if(p==0) a[p]=a[p]+23; if(p==1) a[p]=a[p]+28; if(p==2) a[p]=a[p]+33; } ++k; if(a[0]<=a[3]) cout<<"Case "<<k<<": the next triple peak occurs in "<<21252+a[0]-a[3]<<" days."<<endl; else cout<<"Case "<<k<<": the next triple peak occurs in "<<a[0]-a[3]<<" days."<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator