Alx09

Untitled

Apr 6th, 2019
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. unsigned long long x, y;
  8. cin >> x >> y;
  9. if(x > y)
  10. {
  11. int aux = y;
  12. y = x;
  13. x = aux;
  14. }
  15. unsigned long long k1 = ceil( (-1 + sqrt(1 + 8 * x))/2);
  16. unsigned long long k2 = ceil( (-1 + sqrt(1 + 8 * y))/2);
  17. unsigned long long poz2 = y - k2*(k2-1)/2;
  18. while (x < y)
  19. {
  20. cout << x << ' ';
  21. while( k2 - k1 >= poz2 )
  22. {
  23. x = x + k1;
  24. cout << x <<' ';
  25. k1++;
  26.  
  27. }
  28. x += k1 + 1;
  29. k1++;
  30. }
  31. cout << y;
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment