QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#409419 | #3161. Another Coin Weighing Puzzle | ucup-team1716# | WA | 2ms | 3628kb | C++20 | 964b | 2024-05-12 02:57:40 | 2024-05-12 02:57:41 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll N = 998244353;
//Modded Power
ll mpow(ll a, ll n)
{
if(n==0) return 1;
ll x = mpow(a, n/2);
x = (x*x)%N;
if(n%2==0) return x;
else return (x*a)%N;
}
//Inverse
ll inv(ll a)
{
return mpow(a, N-2);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll n, k;
cin >> k >> n;
vector<ll> ans(n+1, 0);
for(int i=1; i<=n; i++)
{
ans[i] += mpow(i, k) - mpow(i-1, k);
ans[i] += ans[i-1];
for(int j=2*i; j<=n; j+=i)
{
ans[j] -= ans[i] - ans[i-1];
ans[j] %= N;
}
ans[i] = ans[i] % N;
if(ans[i] < 0) ans[i] += N;
}
/*for(ll x: ans) cout << x << " ";
cout << "\n";*/
if(k != 1) cout << (1 + 2 * k + ans[n] * mpow(2, k)) % N;
else cout << 3;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3500kb
input:
2 1
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
2 2
output:
17
result:
ok single line: '17'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 3628kb
input:
10000 10000
output:
722153370
result:
wrong answer 1st lines differ - expected: '689223145', found: '722153370'