跳到正文

休闲·娱乐

后现代主义码风:Tab = -4

TernaryTree约 1 分钟
原文
文章信息与版本

文章信息

发布
2023年9月9日
收录
2025年12月12日
更新
2026年10月28日
篇幅
约 1 分钟
获赞
11

版本

  1. v1当前
C++
			#include <bits/stdc++.h>
			#define int long long
			
			using namespace std;
			
			const int maxn = 1e6 + 10;
			const int maxm = 840;
			
			int n, x, y, q;
			int p[maxn], t[maxn];
			int ans[maxm];
			
			signed main() {
		cin >> n >> x >> y, --n;
		for (int i = 1; i <= n; i++) cin >> p[i] >> t[i];
		for (int i = 0; i < maxm; i++) {
	int s = i;
	for (int j = 1; j <= n; j++) {
s = (s + p[j] - 1) / p[j] * p[j];
s += t[j];
	}
	ans[i] = s - i;
		}
		cin >> q;
		while (q--) {
	int w;
	cin >> w;
	cout << w + x + ans[(w + x) % maxm] + y << endl;
		}
		return 0;
			}