QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#74005 | #3161. Another Coin Weighing Puzzle | UCSC_Ravioli# | WA | 125ms | 3432kb | C++20 | 734b | 2023-01-30 08:29:24 | 2023-01-30 08:29:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int m, k;
cin >> m >> k;
const ll mod = 998244353;
vector<ll> dp(m+1);
dp[0] = 1;
ll x = 1;
ll y = 1;
for(int i=1; i<=m; i++){
x = x*k%mod;
y = y*(k-1)%mod;
dp[i] = x - y;
dp[i] = (dp[i]%mod+mod)%mod;
}
// for(int i=0; i<=m; i++){
// cout << dp[i] << ' ';
// }
// cout << endl;
for(int i=m; i>=1; i--){
vector<ll> ndp(m+1);
for(int j=0; j<m; j++){
ndp[j] = dp[j] + 2*dp[j+1];
ndp[j] %= mod;
// cout << i << " weighings, bits = " << j << ": " << dp[i][j] << endl;
}
swap(dp, ndp);
}
cout << dp[0] << endl;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3384kb
input:
2 1
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3400kb
input:
2 2
output:
17
result:
ok single line: '17'
Test #3:
score: -100
Wrong Answer
time: 125ms
memory: 3432kb
input:
10000 10000
output:
843432142
result:
wrong answer 1st lines differ - expected: '689223145', found: '843432142'