QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#539304 | #6810. Array Concatenation | ucup-team1329# | WA | 0ms | 3532kb | C++20 | 2.2kb | 2024-08-31 14:27:34 | 2024-08-31 14:27:41 |
Judging History
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 = ans2, 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';
// if (ans1 >= ans2) {
// MOD(ans1);
// MOD(ans2);
// MOD(sum);
// } else {
// MOD(ans1);
// MOD(ans2);
// MOD(sum);
// for (int i = 0; i < m; i++) {
// MOD(ans += sum * i % mod + ans1);
// }
// for (int i = 0; i < m; i++) {
// MOD(ans += sum * i % mod + ans1);
// }
// }
// std::cout << ans << '\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: 0
Wrong Answer
time: 0ms
memory: 3532kb
input:
2 1 1 2
output:
16
result:
wrong answer 1st lines differ - expected: '15', found: '16'