#include <cstdio>
using namespace std;
int D, x, y, M = 21252, num;
int a[3], m[3] = {23, 28, 33}, inv;
int exgcd(int a, int b, int &x, int &y) {
if (!b) {
x = 1;
y = 0;
return a;
}
int t = exgcd(b, a % b, x, y);
long long tmp = x;
x = y;
y = tmp - a / b * y;
return t;
}
int main() {
while (1) {
num += 1;
x = 0;
scanf("%d%d%d%d", &a[0], &a[1], &a[2], &D);
if (a[0] == -1 and a[1] == -1 and a[2] == -1 and D == -1)
break;
for (int i = 0; i < 3; i += 1) {
exgcd(M / m[i], m[i], inv, y);
x = (x + 1ll * M / m[i] * a[i] * inv) % M;
}
if (x <= D)
x += M;
printf("Case %d: the next triple peak occurs in %d days.\n", num, x - D);
}
return 0;
}
一本通1639:Biorhythms
最新推荐文章于 2024-08-23 11:07:46 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)