Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

扫描一个最大公倍数周期内的长度得到所有情况

Posted by nuclearMoonlit at 2018-05-31 01:04:52 on Problem 1006
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator