| ||||||||||
| 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 | |||||||||
扫描一个最大公倍数周期内的长度得到所有情况#include<iostream>
using namespace std;
int main()
{
int p, e, i, j, k, d, b, index, f[23][28][33], distance, pi, pj, pk;
distance = 21251;
i = 22;
j = 27;
k = 32;
pi = 23;
pj = 28;
pk = 33;
while (distance >= 0) {
f[i--][j--][k--] = distance--;
if (i == -1)i = pi-1;
if (j == -1)j = pj-1;
if (k == -1)k = pk-1;
}
index = 0;
while (cin >> p >> e >> i >> d, p != -1) {
b = f[p%pi][e%pj][i%pk];
while (d >= b)b += 21252;
cout << "Case "<<++index<<": the next triple peak occurs in "<<b-d<<" days." << endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator