QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#364692 | #3161. Another Coin Weighing Puzzle | chuchu# | WA | 1ms | 3828kb | C++23 | 703b | 2024-03-24 16:05:57 | 2024-03-24 16:05:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll P = 998244353;
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;
}
void solve() {
ll m, k; cin >> m >> k;
vector<ll>dp(k+1);
for(int i = 1 ; i <= k ; i ++) {
dp[i] = qpow(2*i+1, m);
}
for(int i = 1 ; i <= k ; i ++) {
for(int j = 2 * i ; j <= k ; j += i) {
dp[j] = (dp[j] - dp[i] + 1) % P;
}
}
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: 3604kb
input:
2 1
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 2
output:
17
result:
ok single line: '17'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3612kb
input:
10000 10000
output:
453898334
result:
wrong answer 1st lines differ - expected: '689223145', found: '453898334'