#include <bits/stdc++.h> #define MAX 1000000 using namespace std; int main() { int n; int dp[MAX]; while (cin >> n) { memset(dp, 0, sizeof(dp)); dp[0] = 1; for (int i = 1; i <= n; i *= 2) { for (int j = i; j <= n; j++) { dp[j] = (dp[j] + dp[j - i]) % 1000000000; //不取+取 } } cout << dp[n] % 1000000000 << endl; } }