QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#617346#6810. Array ConcatenationYshanqianWA 1ms5692kbC++201.5kb2024-10-06 15:03:072024-10-06 15:03:07

Judging History

你现在查看的是最新测评结果

  • [2024-10-06 15:03:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5692kb
  • [2024-10-06 15:03:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(0), cin.tie(0)
#define int long long
#define ll long long
#define int128 __int128
#define ull unsigned long long
#define endl "\n"
#define pi acos(-1)
#define pii pair<int, int>
const double eps = 1e-6;
const int N = 1e6 + 10, M = 1010, INF = 0x3f3f3f3f;
const int mod = 1000000007;
int a[N];
int b[N];
int qmi(int x, int y)
{
    int ans = 1;
    while (y)
    {
        if (y & 1)
            ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}
void solve()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int ans = 0;
    int y = qmi(2, m);
    int u = y * (y + 1) % mod * qmi(2, mod - 2) % mod;
    int t = u % mod * n % mod;
    for (int i = 1; i <= n; i++)
    {
        int cnt = t * a[i] % mod;
        ans = (ans + cnt) % mod;
        t = (t - y + mod) % mod;
    }
    int ans2 = 0;
    int r = qmi(2, m - 1);
    int tt = r * (2 + (r - 1 + mod) % mod * 2 % mod * n % mod) * qmi(2, mod - 2) % mod;
    int yy = ((2 * n - 1) % mod * qmi(2, m - 1) % mod + tt) % mod;
    for (int i = 1; i <= n; i++)
    {
        int cnt = (tt + yy) % mod * a[i] % mod;
        ans2 = (ans2 + cnt) % mod;
    }
    cout << max(ans, ans2) << endl;
}
signed main()
{
    ios;
    int T = 1;
    // cin >> T;
    // cout << fixed << setprecision(8);
    for (int i = 1; i <= T; i++)
    {
        // cout << "Case " << i << ": ";
        solve();
    }

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5608kb

input:

2 1
1 2

output:

15

result:

ok single line: '15'

Test #2:

score: 0
Accepted
time: 0ms
memory: 5692kb

input:

5 10
26463 39326 86411 75307 85926

output:

806275469

result:

ok single line: '806275469'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 5628kb

input:

3 10000
329770536 859936159 696111818

output:

9530648

result:

wrong answer 1st lines differ - expected: '325223749', found: '9530648'