poj 1006

poj 1006

中国剩余定理

#include<iostream>
using namespace std;
int main()
{
		int ncase = 0;
		int p,e,i,d;
        while (true) {
			ncase++;
			cin>>p>>e>>i>>d;
			if (p == -1)
				return 0;
			int ans = (5544 * p + 14421 * e + 1288 * i-d+21252) % 21252;
			if(ans==0)
				ans=21252;
			cout<<"Case "<<ncase<<": the next triple peak occurs in "<<ans<<" days."<<endl;
		}
        return 0;
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注