Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define pb push_back
- #define ld long double
- #define llong long long
- #define F first
- #define S second
- #define null nullptr
- #define TIME 1.0*clock()/CLOCKS_PER_SEC
- #define endl '\n'
- using namespace std;
- const int N = 1e3 + 1e3;
- const int M = 5e5 + 5;
- const int sz = 1399;
- const ld eps = 0.00000001;
- int32_t main() {
- #ifdef LOCAL
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- #else
- // freopen("division.in","r",stdin);
- // freopen("division.out","w",stdout);
- #endif
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int x, y;
- cin >> x >> y;
- set <int> a, b;
- llong s = 0;
- for(int i = 1; s <= x; i++) {
- int ost = x - s;
- // cerr << s << endl;
- if (ost >= i) {
- if (i + s > x) break;
- a.insert(i);
- s += i;
- } else {
- int kek = i - ost;
- if (s - kek + i > x) break;
- a.erase(kek);
- s -= kek;
- a.insert(i);
- s += i;
- }
- if (s == x) break;
- }
- s = 0;
- for(int i = 1; i + s <= y; i++) {
- if (a.count(i)) continue;
- int ost = x - s;
- if (ost >= i) {
- if (i + s > y) break;
- b.insert(i);
- s += i;
- } else {
- int kek = i - ost;
- if (s - kek + i > y) break;
- b.erase(kek);
- s -= kek;
- b.insert(i);
- s += i;
- }
- if (s == y) break;
- }
- cout << a.size() << endl;
- for(auto &to: a) {
- cout << to << ' ';
- }
- cout << endl;
- cout << b.size() << endl;
- for(auto &to: b) {
- cout << to << ' ';
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement