QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#544624 | #8723. 乘二 | shiqiaqiaya# | WA | 151ms | 5176kb | C++14 | 958b | 2024-09-02 19:13:31 | 2024-09-02 19:13:31 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k, mx = 0;
const int mod = 998244353;
priority_queue<int, vector<int>, greater<int>> q;
cin >> n >> k;
int ans = 0;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
mx = max(mx, x);
q.push(x);
(ans += x) %= mod;
}
auto ksm = [&](int a, int x) -> int {
int s = 1;
while (x) {
if (x & 1) s = s * a % mod;
a = a * a % mod;
x >>= 1;
}
return s;
};
while (q.top() * 2 < mx && k) {
int u = q.top();
q.pop();
q.push(2 * u % mod);
(ans += u) %= mod;
k--;
}
ans = ans * ksm(2, k / n) % mod;
k %= n;
while (k && q.size()) {
k--;
(ans += q.top()) %= mod;
q.pop();
}
cout << ans << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 151ms
memory: 5176kb
input:
200000 1605067 366760624 67854 93901 693975 27016 1046 10808 6533158 54778 500941023 77236442 32173 10431454 2 9726 1553148 89282 411182309 494073 131299543 249904771 7906930 353 9909 3632698 29156 1917186 303 737 1189004 22 1983 263 711 4106258 2070 36704 12524642 5192 123 2061 22887 66 380 1 10153...
output:
970069728
result:
wrong answer 1st numbers differ - expected: '707034173', found: '970069728'