QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#409419#3161. Another Coin Weighing Puzzleucup-team1716#WA 2ms3628kbC++20964b2024-05-12 02:57:402024-05-12 02:57:41

Judging History

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

  • [2024-05-12 02:57:41]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3628kb
  • [2024-05-12 02:57:40]
  • 提交

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'