QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602581#8723. 乘二UESTC_OldEastWest#RE 0ms0kbC++171.1kb2024-10-01 10:54:232024-10-01 10:54:23

Judging History

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

  • [2024-10-01 10:54:23]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-01 10:54:23]
  • 提交

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
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3 3
7 2 1

output:


result: