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

不用中国剩余定理,效率跟你一样

Posted by sicojuy at 2010-12-07 16:47:25 on Problem 1006
In Reply To:用中国剩余定理预处理,然后。。 Posted by:Nstd at 2010-08-06 22:53:08
#include <cstdio>

int main()
{
    int p, e, i, d, n, t = 0;
    while(scanf("%d%d%d%d", &p, &e, &i, &d), p != -1)
    {
		p %= 23;
		e %= 28;
		i %= 33;
		n = i;
        while(n % 28 != e)
            n += 33;
        while(n % 23 != p)
            n += 924;
		n -= d;
        if(n <= 0)
            n += 21252;
       printf("Case %d: the next triple peak occurs in %d days.\n", ++t, n);
    }
    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