Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N = 10e5;
int x = 1;
void DGS()
{
  int n; cin>>n;
  vector<int> v;
  ll sum = 1;
    sum = (n*(n+1))/2;
  // cout<<sum<<' ';
  int ind;
  for(int i=1;i<=n;i++) {
    sum = (i*(i+1))/2;
    if(sum == n) ind = i;
  }
  cout<<ind<<'\n';
  for(int 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
1077 ms
260 KB
Time Limit Exceeded