bzoj1677

我還以爲要發現點什麼結論
竟然 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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章