Source Code
#include <bits/stdc++.h>
using namespace std;
long long x;
vector<int>v;
int main()
{
	cin>>x;
	int i = 1;
	while(i <= x)
	{
		v.push_back(i);
		x-=i;
		i++;
	}
	if(x)v[v.size() - 1]+=x;
	cout<<v.size()<<endl;
	for(auto i : v)cout<<i<<" ";
}
Copy
Want More! asmaa_raafat
GNU G++17
239 ms
16.2 MB
Accepted