Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main()
- {
- ll int n, x, y;
- cin>>n>>x>>y;
- vector<ll int> p(n-1), t(n-1);
- for(int i=0; i<n-1; i++)
- cin>>p[i]>>t[i];
- vector<ll int> ans(840);
- for(int i=0; i<840; i++)
- {
- ll int tot = i+x;
- for(int j=0; j<n-1; j++)
- tot = ((tot + p[j] - 1) / p[j]) * p[j] + t[j];
- tot += y;
- ans[i] = tot;
- }
- int q;
- cin>>q;
- while(q--)
- {
- int tmp;
- cin>>tmp;
- cout<<(tmp/840)*840 + ans[tmp%840]<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment