| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
注意,结果有可能得负值注意,有可能得负值,这时结果要加上21252
刚AC,粘一下我的代码,希望对大家有帮助
#include <iostream>
using namespace std;
void main()
{
int p, e, i, d;
int a1 = 5544, a2 = 14421, a3 = 1288;//这三个常数可根据同余定理求得
int j = 1;
int n;
while (true)
{
cin>>p>>e>>i>>d;
if (-1 == p) break;
p %= 23; e %= 28; i %= 33;
n = (a1*p+a2*e+a3*i) % 21252;
cout<<"Case "<<j++ <<": the next triple peak occurs in "
<< (n - d>0?n-d:21252 + n - d)
<<" days.\n";
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator