QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#409424#3161. Another Coin Weighing Puzzleucup-team1716#WA 1ms3860kbC++20936b2024-05-12 03:19:412024-05-12 03:19:42

Judging History

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

  • [2024-05-12 03:19:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3860kb
  • [2024-05-12 03:19:41]
  • 提交

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];
}

详细

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 '