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

why wrong answer? 

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