QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#751511 | #8834. Formal Fring | ucup-team1004 | AC ✓ | 161ms | 15628kb | C++17 | 1.1kb | 2024-11-15 19:12:40 | 2024-11-15 19:12:43 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
const int N=1e6+10,mod=998244353;
int n,f[N],g[N],h[N];
int main(){
scanf("%d",&n);
f[1]=1;
for(int k=0;(1<<k)<n;k++){
for(int i=1<<k;i<=n;i++)(f[i]+=f[i-(1<<k)])%=mod;
}
g[0]=1;
for(int i=1;i<=n;i++){
if(i%2==0)(g[i]+=g[i/2])%=mod;
for(int k=0;(1<<k+1)<=i&&i%(1<<k)==0;k++){
g[i]=(g[i]+1ll*g[i-(1<<k+1)>>k]*f[1<<k])%mod;
}
}
h[0]=1;
for(int k=0;(1<<k)<n;k++){
for(int i=1<<k;i<=n;i++)(h[i]+=h[i-(1<<k)])%=mod;
}
debug(ary(f,1,n));
debug(ary(g,1,n));
for(int i=1;i<=n;i++){
int ans=0;
for(int k=0;(1<<k)<=i;k++){
int x=i%(1<<k),y=i-x-(1<<k),z=(1<<k)-x;
if(__lg(i+z)==__lg(i-z))continue;
ans=(ans+1ll*g[y>>k]*h[x])%mod;
}
printf("%d%c",ans,"\n "[i<n]);
}
return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 8048kb
input:
10
output:
1 1 2 1 1 3 6 1 1 2
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 7916kb
input:
70
output:
1 1 2 1 1 3 6 1 1 2 2 5 5 11 26 1 1 2 2 4 4 6 6 11 11 16 16 27 27 53 166 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 37 37 48 48 64 64 80 80 107 107 134 134 187 187 353 1626 1 1 2 2 4 4 6
result:
ok 70 numbers
Test #3:
score: 0
Accepted
time: 161ms
memory: 15628kb
input:
1000000
output:
1 1 2 1 1 3 6 1 1 2 2 5 5 11 26 1 1 2 2 4 4 6 6 11 11 16 16 27 27 53 166 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 37 37 48 48 64 64 80 80 107 107 134 134 187 187 353 1626 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 36 36 46 46 60 60 74 74 94 94 114 114 140 140 166 166 203 203 240 240 288 288 336 336 400 ...
result:
ok 1000000 numbers
Extra Test:
score: 0
Extra Test Passed