Source Code
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair <int,int>
#define F first
#define S second
#define ever (;;)

ll x;
vector <int> v;

int main()
{
    scanf("%lld",&x);

    for(int i=1;;i++)
    {
        if( x >= i+i+1 )
        {
            x -= i;
            v.push_back(i);
        }
        else
        {
            v.push_back(x);
            break;
        }
    }

    int sz = (int)(v.size());
    printf("%d\n",sz);
    for(int i=0;i<sz;i++)
        printf("%d%c",v[i],(i==sz-1)?'\n':' ');
}
Copy
Want More! Naseem17
GNU G++17
118 ms
16.8 MB
Accepted