POJ 1006 Biorhythms 手算孙子定理

Posted legend_PawN

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了POJ 1006 Biorhythms 手算孙子定理相关的知识,希望对你有一定的参考价值。

POJ1006

题目给的mod数组是固定,直接手算吧
AC代码:

#include <iostream>
#include <cstdio>
using namespace std;
int main()
    //freopen("input.txt","r",stdin);
    int p,e,i,d,cnt=0;
    while(~scanf("%d%d%d%d",&p,&e,&i,&d))
        if(p==-1 && e==-1 && i==-1 && d==-1)
            break;
        int ans=(5544*(p%23)+14421*(e%28)+1288*(i%33) )%21252;
        ans-=d;
        ans=(ans+21252)%21252;  //防止ans为负值,加mod取mod
        if(ans==0)
            ans=21252;
        printf("Case %d: the next triple peak occurs in %d days.\\n",++cnt,ans);
    
    return 0;

以上是关于POJ 1006 Biorhythms 手算孙子定理的主要内容,如果未能解决你的问题,请参考以下文章

POJ1006Biorhythms——中国剩余定理

Biorhythms POJ - 1006

poj 1006 Biorhythms

POJ——T 1006 Biorhythms

poj1006-biorhythms中国剩余定理

poj1006 Biorhythms