QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628461#6810. Array ConcatenationfoyonaczyWA 0ms3672kbC++201.0kb2024-10-10 20:24:012024-10-10 20:24:05

Judging History

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

  • [2024-10-10 20:24:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3672kb
  • [2024-10-10 20:24:01]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long
constexpr int MOD = 1e9 + 7;

int qpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

int f[300005];

signed main() {
    int n, m;
    std::cin >> n >> m;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        std::cin >> x;
        sum = (sum + x) % MOD;
    }
    f[2] = 4;
    for (int i = 3; i <= m; i++) {
        f[i] = (f[i - 1] * 2 % MOD + qpow(4, i - 1)) % MOD;
    }
    int ans = 0;
    int k = sum * n % MOD;
    for (int i = 1; i < m; i++) {
        int a = sum * qpow(2, i - 1) % MOD * ((n * qpow(2, i) % MOD + 1) % MOD) % MOD;
        int N = m - i + 1;
        int tmp = (qpow(2, N - 1) * a % MOD + k * f[N] % MOD) % MOD;
        ans = std::max(ans, tmp);
        k = k * 2 % MOD;
    }
    ans = std::max(ans, sum * qpow(2, m - 1) % MOD * ((n * qpow(2, m) % MOD + 1) % MOD) % MOD);
    std::cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1
1 2

output:

15

result:

ok single line: '15'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

5 10
26463 39326 86411 75307 85926

output:

806275469

result:

ok single line: '806275469'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3672kb

input:

3 10000
329770536 859936159 696111818

output:

999797275

result:

wrong answer 1st lines differ - expected: '325223749', found: '999797275'