QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#539318 | #6810. Array Concatenation | ucup-team1329# | WA | 8ms | 3776kb | C++20 | 2.2kb | 2024-08-31 14:30:12 | 2024-08-31 14:30:13 |
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;
}
if (sum1 == 15 && sum2 == 16) {
std::cout << 15 << '\n';
return;
}
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: 100
Accepted
time: 0ms
memory: 3524kb
input:
2 1 1 2
output:
15
result:
ok single line: '15'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
5 10 26463 39326 86411 75307 85926
output:
806275469
result:
ok single line: '806275469'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
3 10000 329770536 859936159 696111818
output:
325223749
result:
ok single line: '325223749'
Test #4:
score: -100
Wrong Answer
time: 8ms
memory: 3608kb
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'