后现代主义码风:Tab = -4
TernaryTree · · 休闲·娱乐
#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;
}