Source Code
#include<bits/stdc++.h>
#define ll long long 

using namespace std;
ll MOD = 1e9 + 7 ;
ll bigMod(ll x,ll y){
    if (y == 0)return 1;
    if (y == 1)return x;
    ll res = bigMod(x , y / 2LL);
    res *= res;
    res %= MOD;
    if (y % 2){
        res *= x;
        res %= MOD;
    }
    return res;
}
ll fac[1000005];
ll choose(ll x,ll y){
    if (x == y)return 1;
    if (y > x)return 0;
    if (y == 0)return 1;
    ll up = fac[x];
    ll down = fac[y] * fac[x-y];
    down %= MOD;
    ll ret = up * bigMod(down , MOD - 2);
    ret %= MOD;
    return ret;
}

ll n;
int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    vector<ll> v;
    for (ll i=1;i<=2000000;i++){
        if (n - i <= i){
            v.push_back(n);
            break;
        }
        v.push_back(i);
        n -= i;
    }
    cout << v.size() << endl;
    for (ll x : v)cout << x << " ";
    cout << endl;
    return 0;
}
Copy
Want More! Khaled97ha
GNU G++17
161 ms
22.3 MB
Accepted