一道纯数学问题,难度和代码无关。简单说说:
设所求时间为x,则有x=x1*23+p=x2*28+e=x3*33+i。
写成同余式即为:
x % 23 = p
x % 28 = e
x % 33 = i
然后你可以百度“中国剩余定理”
我为什么不贴连接?骚年,你没等过几个小时的审查吧。
想当初,年轻的我以前居然往博文里放超链接,唉!
//PKU_1006
//中国剩余定理,纯数学题
#include <iostream>
using namespace std;
int main() {
int x,y,z,d,i=0,n;
while (cin>>x>>y>>z>>d &&
(x!=-1 || y!=-1 || z!=-1 || d!=-1)) {
i++;
n=(x*5544+y*14421+z*1288)%21252-d;
if (n<=0) n+=21252;
cout<<"Case "<<i
<<": the next triple peak occurs in "<<n
<<" days."<<endl;
}
return 0;
}