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

有好的方法不,我的时间太长 800MS呢

Posted by hyj6393 at 2005-10-06 09:17:49 on Problem 1006
#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:
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