QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#468337 | #8834. Formal Fring | Purslane | RE | 0ms | 0kb | C++14 | 696b | 2024-07-08 20:17:18 | 2024-07-08 20:17:18 |
answer
#include<bits/stdc++.h>
#define ffor(i,a,b) for(int i=(a);i<=(b);i++)
#define roff(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
const int MAXN=1e6+10,MOD=998244353;
int n,dp[MAXN],hb[MAXN],pre[MAXN],rc[MAXN];
int main() {
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n;
hb[1]=1;
ffor(i,2,n+2) hb[i]=hb[i>>1]<<1;
dp[0]=pre[0]=1;
ffor(i,1,n) dp[i]=pre[i>>1],pre[i]=(pre[i-1]+dp[i])%MOD;
ffor(i,1,20) {
rc[i]=dp[(1<<i)-1];
ffor(j,1,i-1) rc[i]=(rc[i]-1ll*rc[j]*dp[(1<<i-j)-1])%MOD;
}
ffor(i,1,n) {
int cnt=0,v=hb[i],u=i,ans=0;
while(i&v) {
cnt++,u-=v,v>>=1;
ans=(ans+1ll*rc[cnt]*dp[u])%MOD;
}
cout<<ans<<' ';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
10