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

Re:中国剩余定理

Posted by first at 2003-11-01 19:59:11 on Problem 1006
In Reply To:中国剩余定理 Posted by:dynamic at 2003-10-31 21:58:52
谢谢dynamic我这样写的可是还要100多ms 不知道为什么?
#include <iostream> 
using namespace std;
int main()
{
   long  int p,e,i,d,casei,day,lcm1,lcm2,lcm3;
   cin>>p>>e>>i>>d;
   casei=1;
   lcm1=1288;
   lcm2=14421;
   lcm3=5544;
   while(p!=-1)
   {	   
          day=lcm1*i+lcm2*e+lcm3*p-d;
		  day%=21252;
	      cout<<"Case "<<casei<<": the next triple peak occurs in "<<
		  (day<=0?day+21252:day)<<" days."<<endl;
	      casei++;
	      cin>>p>>e>>i>>d;
   }
}

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