当成完全背包求解是最容易想到的方法

#include <iostream>
#include <algorithm>
using namespace std;

const int N = 1e6 + 10, mod = 1000000000;

int n;
int f[N];

int main()
{
    cin >> n;
    f[0] = 1;
    for (int i = 1; i <= n; i *= 2)
        for (int j = i; j <= n; ++j)
                f[j] = (f[j] + f[j - i]) % mod;
    cout << f[n] << endl;
    return 0;
}