http://poj.org/problem?id=1006
题意:
(n+d) % 23 = p ;
(n+d) % 28 = e ;
(n+d) % 33 = i ;
求最小的n。
思路:
这道题就是中国剩余定理。
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
using namespace std; int n; int main()
{
//freopen("D:\\txt.txt", "r", stdin);
int p, e, i, d;
int kase = ;
while (cin >> p >> e >> i >> d)
{
if (p == - && e == - && i == - && d == -) break;
int lcm = ;
int n = ( * p + * e + * i - d + ) % ;
if (n == )
n = ;
cout << "Case " << ++kase << ": the next triple peak occurs in " << n << " days." << endl;
}
return ;
}