QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602600#8723. 乘二Komorebie#WA 24ms19976kbC++171.9kb2024-10-01 11:06:452024-10-01 11:06:47

Judging History

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

  • [2024-10-01 11:06:47]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:19976kb
  • [2024-10-01 11:06:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define maxn 200005
#define mod 1000000007
int n, k, x, tot;
#define ll long long
vector<ll> a[50];
ll fp(ll x)
{
    ll ans = 1, y = 2;
    while (x) {
        if (x & 1) {
            x--;
            ans *= y;
            ans %= mod;
        }
        else {
            y *= y;
            y %= mod;
            x >>= 1;
        }
    }
    return ans;
}
void solve()
{
    ll ans = 0;
    int i;
    for (i = 0; i < tot && k; i++) {
        if (k >= a[i].size()) {
            k -= a[i].size();
            for (int j = 0; j < a[i].size(); j++) {
                a[i + 1].push_back(a[i][j] << 1);
            }
        }
        else {
            sort(a[i].begin(), a[i].end());
            for (int j = 0; j < k; j++) {
                ans += (a[i][j] << 1);
            }
            for (int j = k; j < a[i].size(); j++) {
                ans += a[i][j];
            }
            k = 0;
        }
    }
    if (k == 0)
        for (; i <= tot; i++) {
            for (int j = 0; j < a[i].size(); j++) {
                ans += a[i][j];
            }
        }
    else {
        sort(a[tot].begin(), a[tot].end());
        ll x = k / a[tot].size(), y = k % a[tot].size();
        for (int i = 0; i < y; i++) {
            a[tot][i] = a[tot][i] << 1;
            a[tot][i] %= mod;
        }
        for (int i = 0; i < a[tot].size(); i++) {
            ans += (a[tot][i] * fp(x)) % mod;
            ans %= mod;
        }
    }
    cout << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        for (int i = 30; i >= 0; i--) {
            if ((x >> i) & 1) {
                tot = max(i, tot);
                a[i].push_back(x);
                break;
            }
        }
    }
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 24ms
memory: 19976kb

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:

10953707110844

result:

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