QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#364697#3161. Another Coin Weighing Puzzlechuchu#TL 180ms3808kbC++23699b2024-03-24 16:07:582024-03-24 16:07:59

Judging History

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

  • [2024-03-24 16:07:59]
  • 评测
  • 测评结果:TL
  • 用时:180ms
  • 内存:3808kb
  • [2024-03-24 16:07:58]
  • 提交

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 d = 2 ; d <= i ; d ++) {
            dp[i] = (dp[i] - dp[i/d] + 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: 3516kb

input:

2 1

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

2 2

output:

17

result:

ok single line: '17'

Test #3:

score: 0
Accepted
time: 180ms
memory: 3700kb

input:

10000 10000

output:

689223145

result:

ok single line: '689223145'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

9999 31

output:

986106162

result:

ok single line: '986106162'

Test #5:

score: 0
Accepted
time: 173ms
memory: 3644kb

input:

57 9817

output:

447253096

result:

ok single line: '447253096'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

501 499

output:

247755220

result:

ok single line: '247755220'

Test #7:

score: -100
Time Limit Exceeded

input:

97424 174829

output:


result: