QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#409424 | #3161. Another Coin Weighing Puzzle | ucup-team1716# | WA | 1ms | 3860kb | C++20 | 936b | 2024-05-12 03:19:41 | 2024-05-12 03:19:42 |
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);
ans[0] = 1;
for(int i=1; i<=n; i++)
{
ans[i] += mpow(2 * i + 1, k) - mpow(2 * 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 << ans[n];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3860kb
input:
2 1
output:
1 9 9
result:
wrong answer 1st lines differ - expected: '9', found: '1 9 '