QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#602570 | #8723. 乘二 | UESTC_OldEastWest# | RE | 0ms | 0kb | C++20 | 1.1kb | 2024-10-01 10:50:21 | 2024-10-01 10:50:21 |
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int mod = 1e9 + 7;
inline int ksm(int x, int p) {
x %= mod;
int ans = 1;
while (p) {
if (p & 1) ans = ans * x % mod;
x = x * x % mod;
p >>= 1;
}
return ans;
}
inline void Solve() {
int n, k; vector<int> a(n + 1);
cin >> n >> k;
priority_queue<int, vector<int>, greater<int>>q;
for (int i = 1; i <= n; i++) cin >> a[i], q.push(a[i]);
while (k) {
int x = q.top();
if (x >= 1e12) break;
q.pop();
q.push(x * 2);
k--;
}
int times = ksm(2, k / n);
for (int i = 1; i <= n; i++) a[i] = q.top() % mod * times % mod, q.pop();
for (int i = 1; i <= k % n; i++) a[i] = a[i] * 2 % mod;
int ans = 0;
for (int i = 1; i <= n; i++) ans = (ans + a[i]) % mod;
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T--) {
Solve();
}
return 0;
}
/*
3 3
7 2 1
*/
详细
Test #1:
score: 0
Runtime Error
input:
3 3 7 2 1