QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#468340 | #8834. Formal Fring | Purslane | WA | 47ms | 16308kb | C++14 | 696b | 2024-07-08 20:17:49 | 2024-07-08 20:17:50 |
Judging History
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,19) {
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: 100
Accepted
time: 1ms
memory: 9776kb
input:
10
output:
1 1 2 1 1 3 6 1 1 2
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 9776kb
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: -100
Wrong Answer
time: 47ms
memory: 16308kb
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:
wrong answer 8191st numbers differ - expected: '950877075', found: '-47367278'