QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#458208 | #8834. Formal Fring | PhantomThreshold# | AC ✓ | 52ms | 32648kb | C++17 | 1.1kb | 2024-06-29 16:18:00 | 2024-06-29 16:18:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int maxn=2000000;
ll n;
ll f[maxn+50];
ll g[maxn+50];
ll h[maxn+50];
ll lg[maxn+50];
int main(){
ios_base::sync_with_stdio(false);
cin >> n;
f[0]=1;
lg[0]=-1;
for (ll i=1;i<=n;i++){
if (i%2==1) f[i]=f[i-1];
else f[i]=(f[i-1]+f[i/2])%mod;
lg[i]=lg[i/2]+1;
}
h[1]=1;
for (ll i=2;i<=lg[n];i++){
ll now=(1<<i)-1;
h[i]=f[now];
// cout << i << " " << now << endl;
for (ll j=1;j<i;j++){
now=now/2;
h[i]=(h[i]+mod-h[j]*f[now]%mod)%mod;
}
}
// for (int i=1;i<=lg[n];i++) cout << h[i] << " ";
// cout << "\n";
for (ll i=1;i<=n;i++){
// if (i==(1LL<<(lg[i]+1))-1){
// g[i]=f[i];
// continue;
// }
ll now=i;
for (ll j=lg[i];j>=0;j--){
if (((i>>j)&1)==0) break;
now-=1LL<<j;
g[i]=(g[i]+h[lg[i]-j+1]*f[now])%mod;
}
}
for (ll i=1;i<=n;i++) cout << g[i] << " \n"[i==n];
// for (ll i=1;i<=n;i++) cout << setw(2) << f[i] << " \n"[i==n];
// for (ll i=1;i<=n;i++) cout << setw(2) << g[i] << " \n"[i==n];
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7792kb
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: 7796kb
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: 52ms
memory: 32648kb
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