Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- long long n, a, b;
- int w[100000];
- vector <int> x;
- cin >> n >> a >> b;
- for (int i = 0; i < n; i++)
- {
- cin >> w[i];
- if ((w[i] * a) % b == 0)
- {
- x.push_back(0);
- }
- else
- {
- for (int j = w[i] - 1; j >= 0; j--)
- {
- if ((j*a) % b == 0)
- {
- x.push_back(w[i] - j);
- break;
- }
- }
- }
- }
- for (int i = 0; i < x.size(); i++)
- {
- if (i != x.size() - 1)
- cout << x[i] << " ";
- else
- cout << x[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement