Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

感觉这样比较简单,一个是peak点要大于d,一个是peak点小于等于21252,两种特殊情况比较坑

Posted by jyt0507 at 2015-09-14 17:34:12 on Problem 1006
#include <iostream>

using namespace std;
int GetMin(int *b){
    if(b[0]<=b[1]&&b[0]<=b[2]){
        return 0;
    }
    if(b[1]<b[0]&&b[1]<=b[2]){
        return 1;
    }
    if(b[2]<b[0]&&b[2]<b[1]){
        return 2;
    }
    return -1;
}
int main()
{
    int b[4];
    int i=0;
    cin>>b[0]>>b[1]>>b[2]>>b[3];
    while(b[0]!=-1){
        switch(GetMin(b)){
        case 0:b[0]+=23;break;
        case 1:b[1]+=28;break;
        case 2:b[2]+=33;break;
        }
        while(b[0]!=b[1]||b[0]!=b[2]||b[0]<b[3]){
            switch(GetMin(b)){
            case 0:b[0]+=23;break;
            case 1:b[1]+=28;break;
            case 2:b[2]+=33;break;
            }
        }
        i++;
        if((b[0]-b[3])==21252)
            cout<<"Case "<<i<<": the next triple peak occurs in "<<21252<<" days."<<endl;
        else
            cout<<"Case "<<i<<": the next triple peak occurs in "<<(b[0]-b[3])%21252<<" days."<<endl;
        cin>>b[0]>>b[1]>>b[2]>>b[3];
    }
 
    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator