QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#495272 | #6810. Array Concatenation | 333zhan | WA | 0ms | 3784kb | C++20 | 1.3kb | 2024-07-27 19:48:47 | 2024-07-27 19:48:49 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1E9 + 7;
inline int read () {
int w = 1, s = 0; char ch = getchar ();
for (; ! isdigit (ch); ch = getchar ()) if (ch == '-') w = -1;
for (; isdigit (ch); ch = getchar ()) s = (s << 1) + (s << 3) + (ch ^ 48);
return s * w;
}
int power (int x, int p) {
int ans = 1;
for (; p; p >>= 1) {
if (p & 1) ans = ans * x % mod;
x = x * x % mod;
}
return ans;
}
void solve () {
int n, m;
cin >> n >> m;
vector <int> a (n + 1);
for (int i = 1; i <= n; i ++) {
cin >> a[i];
}
const int N = power (2, m - 1);
const int D = 2 * n;
auto work = [&] (int a1) {
return (a1 * N - N * (N - 1) / 2 % mod * D) % mod;
};
int ans = 0;
for (int i = 1; i <= n; i ++) {
ans += work ((N * D - 2 * n + (n - i + 1) + mod) % mod) * a[i];
ans %= mod;
// cerr << i << " " << ans << "\n";
ans += work ((N * D - n + i + mod) % mod) % mod * a[i];
ans %= mod;
// cerr << i << " " << ans << "\n";
}
cout << ans << '\n';
}
signed main () {
ios::sync_with_stdio (false);
cin.tie (nullptr);
int T = 1;
// cin >> T;
// T = read ();
while (T --) {
solve ();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
2 1 1 2
output:
15
result:
ok single line: '15'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
5 10 26463 39326 86411 75307 85926
output:
806275469
result:
ok single line: '806275469'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
3 10000 329770536 859936159 696111818
output:
325223749
result:
ok single line: '325223749'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3524kb
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'