Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- ll n, k, x, y, q;
- cin >> n >> k >> x >> y >> q;
- ll f = (n * y) - (n / k) * y + (n / k) * x;
- ll c = (y * (k - 1) + x);
- while(q--){
- ll a;
- cin >> a;
- a--; a %= f; a++;
- ll ans = ((a - 1) / c) * k;
- a--; a %= c; a++;
- ans += c + 1 - a > x ? (a + y - 1) / y : k;
- cout << ans << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment