Question address: http://poj.org/problem? Id = 1006 & lang = default & change = true
This is the question of a deformed Sun Tzu's theorem, which is used directly by formulas.
CodeAs follows:
# Include <iostream> # include <cstdio> # include <cstdlib> # include <cmath> # include <cstring> # include <string> # include <algorithm> # include <vector> # include <set> # include <map> # include <queue> using namespace STD; /* freopen ("input.txt", "r", stdin); // read data freopen ("output.txt", "W", stdout ); // comment out this sentence and output it to the console */INT main () {int N, LCM, A, B, C, D, casei = 0; int K1, K2, K3; while (CIN> A> B> C> D & (A + B + C + D )! =-4) {LCM = 21252; // lcm (5544, 33); k1 =; // K1 % 28 = k1 % 33 = 0, K1 % 23 = 1; k2 = 14421; // K2 % 23 = k2 % 33 = 0, K2 % 28 = 1; K3 = 1288; // K3 % 28 = K3 % 23 = 0, k3 % 33 = 1; n = (K1 * A + K2 * B + K3 * c-d + LCM) % LCM; If (n = 0) n = LCM; printf ("case % d: The next Triple peak occurs in % d days. \ n ", ++ casei, n);} return 0 ;}