You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.2 KiB
61 lines
1.2 KiB
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int N = 1e5 + 10;
|
|
|
|
int n, num;
|
|
int ans;
|
|
vector<int> c;
|
|
|
|
int main() {
|
|
scanf("%d", &n);
|
|
|
|
for (num = 2;; num++) {
|
|
if (ans + num > n) break;
|
|
ans += num;
|
|
c.push_back(num);
|
|
}
|
|
|
|
int r = n - ans;
|
|
while (r) {
|
|
for (int i = c.size() - 1; i >= 0 && r; i--) {
|
|
c[i] += 1;
|
|
r--;
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < c.size(); i++) cout << c[i] << " ";
|
|
cout << endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
int a[N], al;
|
|
int b[N], bl;
|
|
void mul(int a[], int &al, int b[], int bl) {
|
|
int c[N] = {0}, cl = al + bl;
|
|
for (int i = 1; i <= al; i++)
|
|
for (int j = 1; j <= bl; j++)
|
|
c[i + j - 1] += a[i] * b[j];
|
|
int t = 0;
|
|
for (int i = 1; i <= al + bl; i++) {
|
|
t += c[i];
|
|
c[i] = t % 10;
|
|
t /= 10;
|
|
}
|
|
memcpy(a, c, sizeof c);
|
|
al = cl;
|
|
|
|
while (al > 1 && a[al] == 0) al--;
|
|
}
|
|
|
|
// a[++al] = 1;
|
|
// for (int i = 0; i < c.size(); i++) {
|
|
// int x = c[i];
|
|
// for (bl = 0; x; x /= 10) b[++bl] = x % 10;
|
|
// mul(a, al, b, bl);
|
|
// }
|
|
|
|
// for (int i = al; i; i--) printf("%d", a[i]);
|
|
*/ |