QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#338733#4056. 进制转换Link_Cut_Y#25 92ms237120kbC++201.4kb2024-02-26 10:20:162024-02-26 10:20:23

Judging History

你现在查看的是最新测评结果

  • [2024-02-26 10:20:23]
  • 评测
  • 测评结果:25
  • 用时:92ms
  • 内存:237120kb
  • [2024-02-26 10:20:16]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#define int long long
#define vit vector<int>
#define rep(i, a, b) for (int i = (a); i <= (b); i ++ )
#define rop(i, a, b) for (int i = (a); i < (b); i ++ )
#define dep(i, a, b) for (int i = (a); i >= (b); i -- )

using namespace std;

const int N = 1e7 + 10;
const int mod = 998244353;
int px[N], py[150], pz[150], a[N], b[N];
int n, x, y, z, ans, f[150][2][150];
int cnt = 0, bit[150];
void sub() {
	while (n) bit[ ++ cnt] = n % 3ll, n /= 3ll;
	rep(i, 0, bit[cnt]) f[cnt][i == bit[cnt]][i] = 1;
	dep(i, cnt, 1) rep(j, 0, 2) rep(k, 0, 1) rep(l, 0, 100) {
		if (k and j > bit[i - 1]) continue;
		(f[i - 1][k & (j == bit[i - 1])][l + j] += f[i][k][l]) %= mod;
	} pz[0] = 1; rep(i, 1, 100) pz[i] = pz[i - 1] * z % mod;
	rep(i, 0, 100) (ans += (f[1][0][i] + f[1][1][i]) * pz[i] % mod) %= mod;
	printf("%lld\n", ans - 1); return;
}
signed main() {
	scanf("%lld%lld%lld%lld", &n, &x, &y, &z);
	if (x == 1 and y == 1) { sub(); return 0; }
	px[0] = py[0] = pz[0] = 1;
	rep(i, 1, n) px[i] = px[i - 1] * x % mod;
	rep(i, 1, 50) py[i] = py[i - 1] * y % mod;
	rep(i, 1, 50) pz[i] = pz[i - 1] * z % mod;
	rep(i, 1, n) a[i] = a[i >> 1] + (i & 1);
	rep(i, 1, n) b[i] = b[i / 3] + (i % 3);
	rep(i, 1, n) (ans += px[i] * py[a[i]] % mod * pz[b[i]] % mod) %= mod;
	cout << ans << endl; return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 75ms
memory: 222080kb

input:

9134097 778012792 263448561 839843856

output:

887680205

result:

ok 1 number(s): "887680205"

Test #2:

score: 5
Accepted
time: 92ms
memory: 237120kb

input:

9896386 2948513 263418583 271155379

output:

853292631

result:

ok 1 number(s): "853292631"

Test #3:

score: 5
Accepted
time: 66ms
memory: 221048kb

input:

9150910 827328107 842171962 39947937

output:

534921610

result:

ok 1 number(s): "534921610"

Test #4:

score: 5
Accepted
time: 0ms
memory: 8016kb

input:

9586674634211 1 1 58301262

output:

13306748

result:

ok 1 number(s): "13306748"

Test #5:

score: 5
Accepted
time: 1ms
memory: 6040kb

input:

9774917720998 1 1 609549524

output:

825025220

result:

ok 1 number(s): "825025220"

Test #6:

score: 0
Runtime Error

input:

9765239207265 422503033 1 719749187

output:


result:


Test #7:

score: 0
Runtime Error

input:

9732354736444 277693641 1 501293609

output:


result:


Test #8:

score: 0
Runtime Error

input:

9004409828 377918953 449219487 26422407

output:


result:


Test #9:

score: 0
Runtime Error

input:

9579878149 820453354 218842704 133154415

output:


result:


Test #10:

score: 0
Runtime Error

input:

9475807443 305433821 391589421 170059051

output:


result:


Test #11:

score: 0
Runtime Error

input:

484758270277 372146623 410538257 35340632

output:


result:


Test #12:

score: 0
Runtime Error

input:

473458173541 864158404 220259603 529747800

output:


result:


Test #13:

score: 0
Runtime Error

input:

459992983903 359742981 983942229 552405867

output:


result:


Test #14:

score: 0
Runtime Error

input:

462331701308 665849375 563297194 141092054

output:


result:


Test #15:

score: 0
Runtime Error

input:

9061635042931 746632077 302662913 559990819

output:


result:


Test #16:

score: 0
Runtime Error

input:

9653325901537 559549569 638292572 474780356

output:


result:


Test #17:

score: 0
Runtime Error

input:

9640271229478 619740479 644097590 907038757

output:


result:


Test #18:

score: 0
Runtime Error

input:

9781711161203 988850684 154464719 995932763

output:


result:


Test #19:

score: 0
Runtime Error

input:

9156325004698 915375188 316066096 217969045

output:


result:


Test #20:

score: 0
Runtime Error

input:

9042535293051 906265264 156788435 622201740

output:


result: