题意
求
{
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.
⎩⎨⎧x≡a(mod 23)x≡b(mod 28)x≡c(mod 33)
的
x
≥
d
x\geq d
x≥d的最小整数解。
思路
手推一下中国剩余定理即可。
代码
#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);
}
}