deushiro

Untitled

Jan 8th, 2020
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. int main()
  8. {
  9.     ll n, k, x, y, q;
  10.     cin >> n >> k >> x >> y >> q;
  11.     ll f = (n * y) - (n / k) * y  + (n / k) * x;
  12.     ll c = (y * (k - 1) + x);
  13.     while(q--){
  14.         ll a;
  15.         cin >> a;
  16.         a--; a %= f; a++;
  17.         ll ans = ((a - 1) / c) * k;
  18.         a--; a %= c; a++;
  19.         ans += c + 1 - a > x ? (a + y - 1) / y : k;
  20.         cout << ans << "\n";
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment