Source Code
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>v;
    int g=0;
    for(int i=1; ;i++)
    {
        if(i+g>n)
        break;
        v.push_back(i);
        g+=i;
    }
    int y=n-g;
    v[v.size()-1]+=y;
    for(int i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    cout<<endl;

}


Copy
Want More! CR7
GNU G++17
0 ms
360 KB
Wrong Answer