QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#318091 | #4056. 进制转换 | chy12321 | 0 | 0ms | 0kb | C++14 | 984b | 2024-01-30 15:03:48 | 2024-01-30 15:03:49 |
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int N = 1e7 + 10, MOD = 998244353;
int n;
ll x[N], y[24], z[30], p3[15], ans;
void dfs(int cur, int val, int s) {
if (val > n) return;
if (cur == 15) ans = (ans + x[val] * y[__builtin_popcount(val)] % MOD * z[s]) % MOD;
else for (int i : {0, 1, 2}) dfs(cur + 1, val + i * p3[cur], s + i);
}
int main() {
freopen("ex_conversion1.in", "r", stdin), freopen("conversion.out", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> x[1] >> y[1] >> z[1];
x[0] = y[0] = z[0] = p3[0] = 1;
for (int i = 2; i <= n; i++) x[i] = x[i - 1] * x[1] % MOD;
for (int i = 2; i <= 23; i++) y[i] = y[i - 1] * y[1] % MOD;
for (int i = 2; i <= 29; i++) z[i] = z[i - 1] * z[1] % MOD;
for (int i = 1; i <= 14; i++) p3[i] = p3[i - 1] * 3;
dfs(0, 0, 0);
cout << (ans - 1 + MOD) % MOD << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
9134097 778012792 263448561 839843856
output:
result:
Test #2:
score: 0
Dangerous Syscalls
input:
9896386 2948513 263418583 271155379
output:
result:
Test #3:
score: 0
Dangerous Syscalls
input:
9150910 827328107 842171962 39947937
output:
result:
Test #4:
score: 0
Dangerous Syscalls
input:
9586674634211 1 1 58301262
output:
result:
Test #5:
score: 0
Dangerous Syscalls
input:
9774917720998 1 1 609549524
output:
result:
Test #6:
score: 0
Dangerous Syscalls
input:
9765239207265 422503033 1 719749187
output:
result:
Test #7:
score: 0
Dangerous Syscalls
input:
9732354736444 277693641 1 501293609
output:
result:
Test #8:
score: 0
Dangerous Syscalls
input:
9004409828 377918953 449219487 26422407
output:
result:
Test #9:
score: 0
Dangerous Syscalls
input:
9579878149 820453354 218842704 133154415
output:
result:
Test #10:
score: 0
Dangerous Syscalls
input:
9475807443 305433821 391589421 170059051
output:
result:
Test #11:
score: 0
Dangerous Syscalls
input:
484758270277 372146623 410538257 35340632
output:
result:
Test #12:
score: 0
Dangerous Syscalls
input:
473458173541 864158404 220259603 529747800
output:
result:
Test #13:
score: 0
Dangerous Syscalls
input:
459992983903 359742981 983942229 552405867
output:
result:
Test #14:
score: 0
Dangerous Syscalls
input:
462331701308 665849375 563297194 141092054
output:
result:
Test #15:
score: 0
Dangerous Syscalls
input:
9061635042931 746632077 302662913 559990819
output:
result:
Test #16:
score: 0
Dangerous Syscalls
input:
9653325901537 559549569 638292572 474780356
output:
result:
Test #17:
score: 0
Dangerous Syscalls
input:
9640271229478 619740479 644097590 907038757
output:
result:
Test #18:
score: 0
Dangerous Syscalls
input:
9781711161203 988850684 154464719 995932763
output:
result:
Test #19:
score: 0
Dangerous Syscalls
input:
9156325004698 915375188 316066096 217969045
output:
result:
Test #20:
score: 0
Dangerous Syscalls
input:
9042535293051 906265264 156788435 622201740