Source Code
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x;
    vector<int>v;
	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<<" ";
	puts("");
}
Copy
Want More! moathhamudah
GNU G++17
328 ms
16.2 MB
Accepted