Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     ios::sync_with_stdio(false);
  7.     long y, k, n, x;
  8.  
  9.     cin >> y >> k >> n;
  10.     if (y >= n)
  11.     {
  12.         cout << -1;
  13.         return 0;
  14.     }
  15.     else
  16.     {
  17.         for (x = 1; x<k; ++x)
  18.             if (y+x <=n && (y + x)%k == 0)
  19.             {
  20.                 cout << x << ' ';
  21.                 break;
  22.             }
  23.             else if (y+x > n) // Neu chua tim duoc x ma y+x > n thi x khong xac dinh
  24.             {
  25.                 cout << -1;
  26.                 return 0;
  27.             }
  28.  
  29.         for (x += k; y+x <= n; x+=k)
  30.             cout << x << ' ';
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement