QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#539366#6810. Array Concatenationucup-team1329#WA 8ms3740kbC++201.7kb2024-08-31 14:37:292024-08-31 14:37:29

Judging History

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

  • [2024-08-31 14:37:29]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3740kb
  • [2024-08-31 14:37:29]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using A2 = std::array<i64, 2>;

#define Fast_IOS std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0)

const i64 mod = 1e9 + 7;

template <class T>
T MOD(T& x, i64 p = mod) {
    return x = (x % p + p) % p;
}
template <class T>
T MOD(T&& x, i64 p = mod) {
    return x = (x % p + p) % p;
}

class WORK {
   public:
    int N;

    WORK() {}

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

    void solve() {
        int n, m;
        std::cin >> n >> m;
        std::vector<int> a(n + 1);
        i64 ans1 = 0, ans2 = 0, sum = 0;
        for (int i = 1; i <= n; i++) {
            std::cin >> a[i];
            ans1 += a[i];
            ans2 += a[i] * (n - i + 1);
            ans1 %= mod;
            ans2 %= mod;
            // sum += a[i] * n;
        }
        // i64 ans = 0;
        i64 sum1 = 2 * n + 1, sum2 = ans2;
        for (int i = 1; i < m; i++) {
            sum1 = (sum1 * 2 % mod + n * qpow(2, 2 * i) % mod) % mod;
        }
        sum1 = sum1 * ans1 % mod;
        i64 temp = ans1, p2 = n;
        for (int i = 0; i < m; i++) {
            sum2 = (sum2 * 2 % mod + temp * p2 % mod) % mod;
            temp = temp * 2 % mod;
            p2 = p2 * 2 % mod;
        }
        std::cout << std::max(sum1, sum2) % mod << '\n';
    }
};

int main() {
    Fast_IOS;
    WORK work;
    int T = 1;
    // std::cin >> T;
    while (T--) {
        work.solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1
1 2

output:

15

result:

ok single line: '15'

Test #2:

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

input:

5 10
26463 39326 86411 75307 85926

output:

806275469

result:

ok single line: '806275469'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3480kb

input:

3 10000
329770536 859936159 696111818

output:

325223749

result:

ok single line: '325223749'

Test #4:

score: -100
Wrong Answer
time: 8ms
memory: 3508kb

input:

10 100000
910385778 832405357 79882277 740539785 58009121 361679935 208356273 191444931 327043571 40502864

output:

856552494

result:

wrong answer 1st lines differ - expected: '551220212', found: '856552494'