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 peak[3]; int day[22000]; int move[3]={23,28,33}; int main() { int d,i,j,cases=0; while(scanf("%d%d%d%d",&peak[0],&peak[1],&peak[2],&d) && peak[0]!=-1) { memset(day,0,sizeof(day)); for(i=0;i<3;i++) { peak[i]%=move[i]; day[peak[i]]++; } for(i=1;i<1500;i++) for(j=0;j<3;j++) if(peak[j]+i*move[j]-d<=21252) day[peak[j]+i*move[j]]++; for(i=0;i<=21252+d;i++) if(day[i]==3 && i>d) { printf("Case %d: the next triple peak occurs in %d days.\n",++cases,i-d); break; } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator