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:why wrong answer? Posted by:hahaxiao at 2005-09-16 17:49:28 > //每次找三个数中最小的一个,然后加上相应有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