Source Code
#include<bits/stdc++.h>
#include<chrono>

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
auto start = chrono::steady_clock::now();
void init_code(){
    fast_io;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
}
int main(){
    long long t;
    cin>>t;
    long long n=(-1+sqrt((1+8*t))/2);
    long long a=(n*(n+1))/2;
   
    if(a==t){
        cout<<n<<endl;
        for(long long i=1;i<n+1;i++) cout<<i<<" ";
    }else{
        long long d=t-a;
        if(d<n+1){
            cout<<n<<endl;
            for(long long i=1;i<n;i++) cout<<i<<" ";
            cout<<n+d;
        }else{
            cout<<n+1<<endl;
            for(long long i=1;i<n+1;i++) cout<<i<<" ";
            cout<<d;
        }
    }
   return(0);
}
Copy
Want More! bbmm
GNU G++17
85 ms
11.1 MB
Accepted