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;
    cin >> x;
    ll l=1, r=x;
    while( l<=r ){
        ll mid = l+ (r-l)/2;
        if( mid*(mid+1) <= 2*x ){
            l= mid+1;
            ans = mid;
        }
        else
            r=mid-1;
    } 
    cout << ans <<"\n";
    ll rem=x;
    for(ll i=1 ; i<ans ; i++ ){
        cout << i <<" ";
        rem-=i;
    }
    cout <<  rem;
    return 0 ;
}
Copy
Want More! Rand()
GNU G++17
1100 ms
61.3 MB
Time Limit Exceeded
Test Case #1
0 ms
360 KB
Accepted
Input
1
Output
1
1
Judge Output
1
1
Checker Message
the length and sum is correct.
Test Case #2
0 ms
520 KB
Accepted
Input
3
Output
2
1 2
Judge Output
2
1 2
Checker Message
the length and sum is correct.
Test Case #3
0 ms
476 KB
Accepted
Input
6
Output
3
1 2 3
Judge Output
3
1 2 3
Checker Message
the length and sum is correct.
Test Case #4
1100 ms
61.3 MB
Time Limit Exceeded
Input
758284843011
Output
470529300228
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82...
Judge Output
1231490
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 ...
Checker Message