1003,1004, 1005 too much water, not recordedCode. 1006 is also very simple. It is just a problem of undefined equations, because the problem is not clearly described, or because my mind is dizzy because I am not sleeping at noon, after reading the question several times, I did not understand what the meaning of the data is. I understood it only after reading the Chinese translation several times.
# Include <iostream>
Using namespace STD;
Int main ()
{
Int P, E, I, D;
Int start, Day;
Int COUNT = 1;
While (true)
{
Cin> P> E> I> D;
If (P =-1 & E =-1 & I =-1 & D =-1)
Break;
P = P % 23, E = E % 28, I = I % 33;
If (d <p)
Start = 0;
Else
Start = (D-P)/23 + 1; // Add 1 here, after the given date (excluding the given date)
For (int ix = start; ++ IX)
{
Day = P + 23 * IX;
If (day <E | day <I)
Continue;
If (day-D> 21252)
{
Cout <"case" <count ++ <": The next Triple peak occurs in" <21252 <"days." <Endl;
Break;
}
Else if (day-e) % 28 = 0 & (day-I) % 33 = 0)
{
Cout <"case" <count ++ <": The next Triple peak occurs in" <day-D <"days." <Endl;
Break;
}
}
}
Return 0;
}
The conclusion of this question is that if the Chinese Remainder Theorem is applied, it will be calculated in O (1) time, which is very powerful. For details, see
Http://blog.csdn.net/ChinaCzy/archive/2010/04/29/5544250.aspx