Source Code
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n))
typedef bitset<10> MASK;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main(){
    fast();
    ll x;cin>>x;
    for (ll i = 1; i <=1e6 ; ++i) {
        ll val =i*(i+1)/2;
        if(x - val < 0  || (x - val > 0&&x - (val + i+ 1) < 0 )){
                ll prev = i * (i-1)/2;
                cout<<i-1  + (x!=prev)<<endl;
            for (int j = 1; j <=i-1 ; ++j) {
                cout<<j<< " ";
            }
            if(x!=prev)cout<<x-prev<<" ";
            return 0;
        }
    }
}
Copy
Want More! 7eem
GNU G++17
2 ms
416 KB
Wrong Answer