| ||||||||||
| 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:kelven at 2006-05-28 13:16:00 > #include <iostream>
> using namespace std;
> int main(){
> int days[1000];int num=0;
> int a,b,c,d;
> while(cin>>a>>b>>c>>d)
> {
> if(a==-1&&b==-1&&c==-1&&d==-1)
> break;
> else
> {
> do{
> if(a<=b&&a<=c)
> a+=23;
> else if(b<=a&&b<=c)
> b+=28;
> else if(c<=b&&c<=a)
> c+=33;
> }while(a!=b||a!=c);
> days[num]=a-d;
> num++;
> }}
> for(int i=0;i<num;i++)
> cout<<"Case "<<(i+1)<<": the next triple peak occurs in "<<days[i]<<" days."<<endl;
> return 0;
因为d可能比a,b,c的日期都小,你现在推得的是大于a,b,c的日期,可能出现同一高峰的日期比a,b,c的值都小。可以判断以下所得天数是否大于23*28*33,如果大于的话,减去这个值得倍数,所得的最小天数是结果。
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator