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 |
有好的方法不,我的时间太长 800MS呢#include <iostream.h> #include <stdio.h> #define N 1000 int main() {int p,e,i,d,n,triple[N][4],days,j; n=1; scanf("%d%d%d%d",&p,&e,&i,&d); while(p!=-1||e!=-1&&i!=-1&&d!=-1) {triple[n][0]=p; triple[n][1]=e; triple[n][2]=i; triple[n][3]=d; scanf("%d%d%d%d",&p,&e,&i,&d); n++;} for(j=1;j<n;j++) {days=1; p=triple[j][0]%23; e=triple[j][1]%28; i=triple[j][2]%33; d=triple[j][3]; while((d+days-p)%23!=0||(d+days-e)%28!=0||(d+days-i)%33!=0) days++; printf("Case %d: the next triple peak occurs in %d days.\n",j,days); } 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