Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N = 10e5;
int x = 1;
void DGS()
{
  ll n; cin>>n;
  // vector<int> v;
  ll sum;
  //   sum = (n*(n+1))/2;
  // cout<<sum<<' ';
  ll ind;
  for(ll i=1;i<=n;i++) {
    sum = (i*(i+1))/2;
    if(sum == n) ind = i;
  }
  cout<<ind<<'\n';
  for(ll i=1;i<=ind;i++){
    cout<<i<<' ';
  }
}

int main()
{
	ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
	ll n=1;
	// cin>>n;
	while(n--) {DGS(); cout<<'\n';}
}
Copy
Want More! Zain_burayya
GNU G++17
1096 ms
260 KB
Time Limit Exceeded