QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#628496 | #6810. Array Concatenation | foyonaczy | WA | 7ms | 4408kb | C++20 | 1.0kb | 2024-10-10 20:35:48 | 2024-10-10 20:35:48 |
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: 3636kb
input:
5 10 26463 39326 86411 75307 85926
output:
806275469
result:
ok single line: '806275469'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
3 10000 329770536 859936159 696111818
output:
325223749
result:
ok single line: '325223749'
Test #4:
score: -100
Wrong Answer
time: 7ms
memory: 4408kb
input:
10 100000 910385778 832405357 79882277 740539785 58009121 361679935 208356273 191444931 327043571 40502864
output:
177280949
result:
wrong answer 1st lines differ - expected: '551220212', found: '177280949'