'commit'
This commit is contained in:
61
TangDou/LuoGuBook/P1249_2.cpp
Normal file
61
TangDou/LuoGuBook/P1249_2.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#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]);
|
||||
*/
|
||||
Reference in New Issue
Block a user