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 |
有错吗!!!附源码#include<iostream> using namespace std; int main(){ int p,e,m,h,i=0; int a[100000],b[100000],c[100000],d[100000]; while(cin>>p>>e>>m>>h){ if(p==-1&&e==-1&&m==-1&&h==-1) break; a[i]=p,b[i]=e,c[i]=m,d[i]=h; i++; } for(int j=0;j<i;j++){ int goal=a[j],goal1=a[j],goal2=a[j],k=1,mark1,mark2,num,a1,b1,c1,k0=1; if(goal>b[j]) goal1=b[j]; else goal2=b[j]; if(goal>c[j]) goal=c[j]; else goal2=c[j]; if(goal1==a[j]) mark1=23; if(goal1==b[j]) mark1=28; if(goal1==c[j]) mark1=33; if(goal2==a[j]) mark2=23; if(goal2==b[j]) mark2=28; if(goal2==c[j]) mark2=33; a1=a[j]-(a[j]/23)*23; b1=b[j]-(b[j]/28)*28; c1=c[j]-(c[j]/33)*33; while((goal2-a1)%23!=0||(goal2-b1)%28!=0||(goal2-c1)%33!=0) { goal2=goal2-k0*mark2; k0++; if(goal2<=d[j]) break; } if((goal2-a1)%23==0&&(goal2-b1)%28==0&&(goal2-c1)%33==0&&goal2>d[j]){ cout << "Case " <<j+1<<":" <<" the next triple peak occurs in " <<goal2-d[j] <<" days." <<endl; continue;} k=1; num=mark1+goal1; while((num-a[j])%23!=0||(num-b[j])%28!=0||(num-c[j])%33!=0||(num-d[j])<=0){ k++; num=goal1+k*mark1; } cout << "Case " <<j+1<<":" <<" the next triple peak occurs in " <<num-d[j] <<" days." <<endl; } system("PAUSE"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator