Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #define pb push_back
  4. #define ld long double
  5. #define llong long long
  6. #define F first
  7. #define S second
  8. #define null nullptr
  9. #define TIME 1.0*clock()/CLOCKS_PER_SEC
  10. #define endl '\n'
  11.  
  12. using namespace std;
  13.  
  14. const int N = 1e3 + 1e3;
  15. const int M = 5e5 + 5;
  16. const int sz = 1399;
  17. const ld eps = 0.00000001;
  18.  
  19.  
  20. int32_t main() {
  21. #ifdef LOCAL
  22. freopen("input.txt","r",stdin);
  23. freopen("output.txt","w",stdout);
  24. #else
  25. // freopen("division.in","r",stdin);
  26. // freopen("division.out","w",stdout);
  27. #endif
  28. ios_base::sync_with_stdio(0);
  29. cin.tie(0);
  30. cout.tie(0);
  31. int x, y;
  32. cin >> x >> y;
  33. set <int> a, b;
  34. llong s = 0;
  35. for(int i = 1; s <= x; i++) {
  36. int ost = x - s;
  37. // cerr << s << endl;
  38. if (ost >= i) {
  39. if (i + s > x) break;
  40. a.insert(i);
  41. s += i;
  42. } else {
  43. int kek = i - ost;
  44. if (s - kek + i > x) break;
  45. a.erase(kek);
  46. s -= kek;
  47. a.insert(i);
  48. s += i;
  49. }
  50. if (s == x) break;
  51. }
  52.  
  53. s = 0;
  54.  
  55. for(int i = 1; i + s <= y; i++) {
  56. if (a.count(i)) continue;
  57. int ost = x - s;
  58. if (ost >= i) {
  59. if (i + s > y) break;
  60. b.insert(i);
  61. s += i;
  62. } else {
  63. int kek = i - ost;
  64. if (s - kek + i > y) break;
  65. b.erase(kek);
  66. s -= kek;
  67. b.insert(i);
  68. s += i;
  69. }
  70. if (s == y) break;
  71. }
  72.  
  73. cout << a.size() << endl;
  74. for(auto &to: a) {
  75. cout << to << ' ';
  76. }
  77. cout << endl;
  78. cout << b.size() << endl;
  79. for(auto &to: b) {
  80. cout << to << ' ';
  81. }
  82. cout << endl;
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. return 0;
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement