QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#459126 | #8834. Formal Fring | ucup-team3924# | ML | 0ms | 0kb | C++20 | 1.1kb | 2024-06-29 23:00:36 | 2024-06-29 23:00:37 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
int N;
cin >> N;
vector<vector<int>> knap(30, vector<int>(1000100));
vector<vector<int>> knap2(30, vector<int>(1000100));
knap[5][0] = 1;
for(int i = 4; i >= 0; i --){
knap[i] = knap[i + 1];
int t = 1 << i;
for(int j = t; j <= 1000000; j ++){
knap[i][j] += knap[i][j - t];
}
}
knap2[0][0] = 1;
for(int i = 0; i <= 20; i ++){
if(i)
knap2[i] = knap2[i - 1];
int t = 1 << i;
for(int j = t; j <= 1000000; j ++){
knap2[i][j] += knap2[i][j - t];
}
}
for(int i = 1; i <= N; i ++){
int t = (1 << (31 - __builtin_clz(i)));
int next = t * 2;
int gap = (31 - __builtin_clz((next - i) * 2) - 1);
int left = max(i - t, 1ll);
cout << knap[gap][i] + (gap && i - t? knap2[gap - 1][i - t]:0) << " ";
}
cout << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int N = 1;
//cin >> N;
while(N --){
solve();
}
return 0;
}
详细
Test #1:
score: 0
Memory Limit Exceeded
input:
10
output:
1 1 2 1 1 3 6 1 1 2