QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#76944#3161. Another Coin Weighing PuzzleWTR2007WA 2ms3616kbC++201.2kb2023-02-12 18:35:562023-02-12 18:36:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-12 18:36:00]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3616kb
  • [2023-02-12 18:35:56]
  • 提交

answer

#include<bits/stdc++.h>
#define MULT_TEST 0
#define int long long
using namespace std;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
inline int read() {
	int w = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		w = (w << 1) + (w << 3) + ch - 48;
		ch = getchar();
	}
	return w * f;
}
inline int Pow(int a, int b){
	int ans = 1;
	for(; b; b >>= 1){
		if(b & 1) ans = ans * a % MOD;
		a = a * a % MOD;
	}
	return ans;
}
inline void Solve() {
	int m, k, ans = 1;
	m = read(); k = read();
	vector<int> prime, mu(k + 1);
	vector<bool> vis(k + 1);
	mu[1] = 1;
	for (int i = 2; i <= k; i++) {
		if (!vis[i]) {
			prime.push_back(i);
			mu[i] = -1;
		}
		for (auto p : prime) {
			if (i * p > k) break;
			vis[i * p] = 1;
			mu[p * i] = -mu[i];
			if (i % p == 0) break;
		}
	}
	for (int i = 1; i <= k; i++) {
		ans += mu[i] * (Pow(2 * (k / i) % MOD + 1, m) - 1 + MOD) % MOD;
		ans = (ans % MOD + MOD) % MOD;
	}
	printf("%lld\n", ans);
}
signed main() {
	int T = 1;
#if MULT_TEST
	T = read();
#endif 
	while (T--) Solve();
	return 0;
}

详细

Test #1:

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

input:

2 1

output:

9

result:

ok single line: '9'

Test #2:

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

input:

2 2

output:

17

result:

ok single line: '17'

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3600kb

input:

10000 10000

output:

702250590

result:

wrong answer 1st lines differ - expected: '689223145', found: '702250590'