【数学 中国剩余定理】POJ_1006 Biorhythms

题意

{ x ≡ a ( m o d   23 ) x ≡ b ( m o d   28 ) x ≡ c ( m o d   33 ) \left\{\begin{matrix}x\equiv a(mod\ 23) \\ x\equiv b(mod\ 28) \\ x\equiv c(mod\ 33) \end{matrix}\right. xa(mod 23)xb(mod 28)xc(mod 33)
x ≥ d x\geq d xd的最小整数解。

思路

手推一下中国剩余定理即可。

代码

#include<cstdio>

int a, b, c, d, ans, tot;

int main() {
	while (scanf("%d %d %d %d", &a, &b, &c, &d), a != -1 || b != -1 || c != -1 || d != -1) {
		ans = (5544 * a + 14421 * b + 1288 * c - d + 21252) % 21252;
		if (!ans) ans = 21252;
		printf("Case %d: the next triple peak occurs in %d days.\n", ++tot, ans);
	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值