Source Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <stack>
#include <map>
#include <math.h>
#include <cmath>
#include <string.h>
#include <numeric>
using namespace std;
typedef vector<int> vi ;
typedef long long ll;
#define all(x) (x).begin() , (x).end()
#define allR(x) (x).rbegin() , (x).rend()
#define pb push_back
const int N = 1e6, M=1e6+1, NN=1e8 , MX = 1e9;
const ll MXL=1e18 , MOD = 1e9 + 7, MD= 998244353;
int a[N], deg[N]; 
int main(){
    // freopen("input.txt", "r", stdin);
    ll x, ans;
    scanf("%lld", &x);
    ll rem=x;
    vector<ll> v;
    for(ll i=1 ; rem >= i  ; i++ ){
        v.pb(i);
        rem-=i;
    }
    printf("%d\n", v.size());
    if( rem ) 
        v[v.size()-1] += rem;
    for(auto i: v)
        printf("%lld ", i);
    return 0 ;
}
Copy
Want More! Rand()
GNU G++17
102 ms
22.4 MB
Accepted