#include<iostream> #include<cstdio> using namespace std; #define N 21252 int main() { int p, e, i, d, caseNo = 0; // -1 代表输入结束 while (cin >> p >> e >> i >> d && p != -1) { ++caseNo; int k; for (k = d+1;(k - p) % 23;k++); for (;(k - e) % 28;k+=23); // 跳着取数,确保是p的倍数 for (;(k - i) % 33;k+=28*23); // 跳着取数,确保是p和e的倍数 cout << "Case" << caseNo << ": the next triple peak occurs in " << (k - d) << " days " << endl; } return 0; }