QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418571#8723. 乘二mingqian_233#WA 52ms7856kbC++141.4kb2024-05-23 14:33:452024-05-23 14:33:46

Judging History

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

  • [2024-05-23 14:33:46]
  • 评测
  • 测评结果:WA
  • 用时:52ms
  • 内存:7856kb
  • [2024-05-23 14:33:45]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
using namespace std;
const int mod = 1e9 + 7;
int f_pow(int x, int y) {
    if (y == 1) return x;
    if (y == 0) return 1;
    int t = f_pow(x, y / 2) % mod;
    if (y % 2)
        return t * t % mod * x % mod;
    else
        return t * t % mod;
}

signed main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    int n, k, tot = 0;
    cin >> n >> k;
    vector<pii> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = log2(a[i].first);
        tot += a[i].second;
    }
    vector<int> mult(n);  // 储存这里即将乘2的多少次方
    int ava = (tot + k) / n;
    sort(a.begin(), a.end());
    int m;
    for (m = n - 1; m > 0;m--){
        ava = (tot + k) / (m+1);
        tot -= a[m].second;
        if (a[m].second < ava) break;
    }
    // puts("mult:");
    for (int i = 0; i <= m; i++) {
        mult[i] = ava - a[i].second;
        // cout << mult[i] << ' ';
        k -= mult[i];
        }
        int ans = 0;
        // puts("ava:");
        for (int i = 0; i < n; i++) {
            a[i].first = a[i].first * f_pow(2, mult[i]) % mod;
            if (k) a[i].first = a[i].first * 2 % mod, k--;
            // cout << a[i].first << ' ';
            ans = (ans + a[i].first) % mod;
    }
    cout << ans % mod;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3660kb

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 52ms
memory: 7856kb

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:

609616159

result:

wrong answer 1st numbers differ - expected: '707034173', found: '609616159'