https://codeforces.com/contest/1348/problem/D
我们只关心总量,所以每次分裂的变化是:今天晚上多加了一个1,明天多一个可以分裂的
有点类似二叉树点数
用贪心的方法计算
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
typedef long long LL;
/*
bool pd(int t) {
// if (n <= t) return 1;
int n = ::n;
int mx = 1;
n -= t;
for (int i = t-1; i > 0; i--) {
int tp = min(mx,n/i);
n -= tp*i;
mx += tp;
}
return n==0;
} */
void Out(int t) {
int n = ::n;
int mx = 1;
n -= t;
cout << t-1 << '\n';
for (int i = t-1; i > 0; i--) {
int tp = min(mx,n/i);
n -= tp*i;
mx += tp;
cout << tp << " ";
}
puts("");
//return n==0;
}
LL a[40];
int main() {
int T;
cin >> T;
a[0] = 1;
for (int i = 1; i <= 30; i++) a[i] = a[i-1]*2;
for (int i = 1; i <= 30; i++) a[i] += a[i-1];
while(T--) {
cin >> n;
/* for (LL l = 1,r = n; ; ) {
if (r-l<=1) {
if (pd(l)) {
Out(l);
} else Out(r);
break;
}
LL m = (l+r)>>1;
pd(m) ? r=m : l=m;
}*/
LL tp = 1;
while(a[tp] < n) tp++;
Out(tp+1);
}
}