QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617824 | #8834. Formal Fring | ucup-team2432 | AC ✓ | 89ms | 223116kb | C++17 | 2.2kb | 2024-10-06 17:16:12 | 2024-10-06 17:16:12 |
Judging History
answer
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define ll long long
#define all(v) v.begin(),v.end()
#define sz(v) ((ll)v.size())
#define V vector
#define vi V<int>
#define vll V<ll>
#define eb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define A array
#define pb push_back
#define mset multiset
#define gpumap __gnu_pbds::gp_hash_table
#define ccumap __gnu_pbds::cc_hash_table
#define ui unsigned int
#define ull unsigned ll
#define i128 __int128
#define cerr if (test) cerr
#define freopen if (test) freopen
#define whtest if (test)
using namespace std;
const int test = 0;
namespace jhsy {
constexpr int P = 998244353;
const int N = 1e6,LG = __lg(N);
A<A<ll,N+1>,LG+1> f,g;
void init(const int n = N,const int lg = LG) {
f[0].fill(1);
for (int j = 1; j <= lg; j++) {
for (int i = 0; i <= n; i++) {
f[j][i] = f[j-1][i];
}
const int x = 1<<j;
for (int i = x; i <= n; i++) {
f[j][i] = (f[j][i]+f[j][i-x])%P;
}
}
for (int i = 0; i <= LG; i++) {
g[i][0] = g[i][1] = 1;
}
auto solve = [&](int n) {
const int t = __lg(n);
const int a = 1<<(t - 1),b = n - a,d = (1 << t) - 1,c = n - d;
if (max(a,c) > min(b,d)) {
for (int i = 0; i <= lg; i++) {
g[i][n] = f[i][n];
}
}
else if (a > c) {
for (int i = t; i <= lg; i++) {
g[i][n] = f[lg][n - (1 << t)];
}
}
else {
for (int i = t; i <= lg; i++) {
g[i][n] = (g[i][n]+f[t][n-(1<<t)]);
}
for (int i = t-1; i >= 0; i--) {
if ((d+1)-(1<<i) < c) {
for (int j = i; j <= lg; j++) {
g[j][n] = (g[j][n]+f[j-i][(1<<(t-i))-1]*g[i][n-(1<<t)])%P;
}
}
else {
break;
}
}
}
};
for (int i = 2; i <= n; i++) {
solve(i);
}
}
void main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cout << g[LG][i] << " \n"[i == n];
}
}
}
int main() {
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
jhsy::init();
int T = 1;
// cin >> T;
while (T--) {
jhsy::main();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 40ms
memory: 223116kb
input:
10
output:
1 1 2 1 1 3 6 1 1 2
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 48ms
memory: 220564kb
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: 89ms
memory: 219724kb
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