QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#364727#3161. Another Coin Weighing Puzzlechuchu#TL 866ms6524kbC++14715b2024-03-24 16:16:042024-03-24 16:16:04

Judging History

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

  • [2024-03-24 16:16:04]
  • 评测
  • 测评结果:TL
  • 用时:866ms
  • 内存:6524kb
  • [2024-03-24 16:16:04]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
constexpr ll P = 998244353;

inline ll qpow(ll a, ll b)
{
	ll ans = 1;
	for (; b; b /= 2, a = a * a % P) {
		if (b % 2 == 1)
			ans = ans * a % P;
	}
	return ans;
}
ll dp[1000010];
void solve()
{
	ll m, k;
	cin >> m >> k;

	for (int i = 1; i <= k; i++) {
		dp[i] = qpow(2 * i + 1, m);
	}

	for (int i = 1; i <= k; i++) {
		for (int d = 2; d <= i;) {
			int k = i / d;
			int nxt = min(i, i / k);
			dp[i] = (dp[i] - (dp[k] - 1) * (nxt - d + 1)) % P;
			d = nxt + 1;
		}
	}

	cout << (dp[k] + P) % P << endl;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	solve();

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3684kb

input:

2 1

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

2 2

output:

17

result:

ok single line: '17'

Test #3:

score: 0
Accepted
time: 10ms
memory: 3796kb

input:

10000 10000

output:

689223145

result:

ok single line: '689223145'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

9999 31

output:

986106162

result:

ok single line: '986106162'

Test #5:

score: 0
Accepted
time: 10ms
memory: 3744kb

input:

57 9817

output:

447253096

result:

ok single line: '447253096'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

501 499

output:

247755220

result:

ok single line: '247755220'

Test #7:

score: 0
Accepted
time: 713ms
memory: 5960kb

input:

97424 174829

output:

964884269

result:

ok single line: '964884269'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

11 13

output:

729153057

result:

ok single line: '729153057'

Test #9:

score: 0
Accepted
time: 866ms
memory: 5236kb

input:

200000 200000

output:

803771125

result:

ok single line: '803771125'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

199999 562

output:

865836540

result:

ok single line: '865836540'

Test #11:

score: 0
Accepted
time: 800ms
memory: 5712kb

input:

3539 189423

output:

530738158

result:

ok single line: '530738158'

Test #12:

score: 0
Accepted
time: 703ms
memory: 6524kb

input:

198324 173852

output:

963717515

result:

ok single line: '963717515'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

1 1

output:

3

result:

ok single line: '3'

Test #14:

score: -100
Time Limit Exceeded

input:

1000000 1000000

output:


result: