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 yaohua2000 at 2003-11-02 01:10:41 on Problem 1006
In Reply To:Re:中国剩余定理 Posted by:first at 2003-11-01 19:59:11
你用这个程序试试? submit了5次,最快一次40毫秒。

#include <stdio.h>

int main(void)
{
	int j, p, e, i, d, days[23][28][33];
	p = e = i = 0;
	for(j = 0; j < 21252; j++)
	{
		days[p][e][i] = j;
		p = p == 22 ? 0 : p + 1;
		e = e == 27 ? 0 : e + 1;
		i = i == 32 ? 0 : i + 1;
	}
	for(j = 0; scanf("%d%d%d%d", &p, &e, &i, &d) != EOF && p >= 0 && e >= 0 && i >= 0 && d >= 0; j++)
	{
		p %= 23;
		e %= 28;
		i %= 33;
		printf("Case %d: the next triple peak occurs in %d days.\n", j + 1, (days[p][e][i] - d + 21251) % 21252 + 1);
	}
	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