我還以爲要發現點什麼結論
竟然 nlogn 暴力過了
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i=(s);i<=(t);i++)
inline int read(void){
int x = 0, c, f = 1;
do{c=getchar();if(c=='-')f=-1;}while(c<'0'||c>'9');
do{x=x*10+c-'0';c=getchar();}while(c>='0'&&c<='9');
return x * f;
}
const int N = 1100000, mod = 1000000000;
int f[N], n, m;
int main() {
n = read();
m = log2(n);
f[0] = 1;
for (int i = 0; i <= m; i++)
for (int j = (1 << i); j <= n; j++)
f[j] = (f[j] + f[j - (1 << i)]) % mod;
cout << f[n] << endl;
}