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

g++AC,c++超时,用的是一一列举,能有更好的办法吗?

Posted by hushuoqiu at 2005-09-27 07:59:01 on Problem 1006
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[])
{
  int p,e,i,d,j,k=1;
  cin>>p>>e>>i>>d;
  while(p!=-1)
  {
  p=p%23;e=e%28;i=i%33;
  for(j=d+1;;j++)if((j-p)%23==0&&(j-e)%28==0&&(j-i)%33==0) break;
  cout<<"Case "<<k<<": the next triple peak occurs in "<<j-d<<" days."<<endl;
  k++;
  cin>>p>>e>>i>>d;
  }
  //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