Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- ios::sync_with_stdio(false);
- long y, k, n, x;
- cin >> y >> k >> n;
- if (y >= n)
- {
- cout << -1;
- return 0;
- }
- else
- {
- for (x = 1; x<k; ++x)
- if (y+x <=n && (y + x)%k == 0)
- {
- cout << x << ' ';
- break;
- }
- else if (y+x > n) // Neu chua tim duoc x ma y+x > n thi x khong xac dinh
- {
- cout << -1;
- return 0;
- }
- for (x += k; y+x <= n; x+=k)
- cout << x << ' ';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement