QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#628461 | #6810. Array Concatenation | foyonaczy | WA | 0ms | 3672kb | C++20 | 1.0kb | 2024-10-10 20:24:01 | 2024-10-10 20:24:05 |
Judging History
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';
}
详细
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'