fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define oo 1000000007
  4. #define maxN 100005
  5. #define debug(a) cout << #a << " = " << a << endl
  6. #define fdebug(a, x, y) { cout << #a << " : "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
  7. #define fto(i, x, y) for(int i = (x); i != (y) + (((x) < (y) ? 1 : -1)); i += ((x) < (y)) ? 1 : -1)
  8. #define ftoa(i, x, y, a) for(int i = (x); i != (((x) < (y)) ? (((y)-(x))/a+1)*a+(x) : (x)-(((x)-(y))/a+1)*a); i += ((x) < (y)) ? (a) : -(a))
  9. #define mp make_pair
  10. #define pb push_back
  11. #define pf push_front
  12. #define ll long long
  13. #define lb lower_bound
  14. #define ub upper_bound
  15. #define ull unsigned long long
  16. #define ii pair<int, int>
  17. #define vi vector<int>
  18. #define vii vector<ii>
  19. #define FF first
  20. #define SS second
  21. #define mt make_tuple
  22. #define eb emplace_back
  23.  
  24. using namespace std;
  25.  
  26. int main() {
  27. #ifndef ONLINE_JUDGE
  28. freopen("template.inp", "r", stdin);
  29. freopen("template.ans", "w", stdout);
  30. #endif // ONLINE_JUDGE
  31.  
  32.  
  33. int n, m, k;
  34. scanf("%d%d%d", &n, &m, &k);
  35.  
  36. for (int i = n; i <= m; i += k) cout << i << " ";
  37. puts("");
  38. for (int i = m; i >= n; i -= k) cout << i << " ";
  39.  
  40. #ifndef ONLINE_JUDGE
  41. cout << endl;
  42. cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  43. #endif
  44.  
  45. return 0;
  46. }
  47.  
  48.  
Success #stdin #stdout 0s 3472KB
stdin
1 10 2
stdout
1 3 5 7 9 
10 8 6 4 2