QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#495276#6810. Array Concatenation333zhanWA 0ms3744kbC++201.4kb2024-07-27 19:49:422024-07-27 19:49:43

Judging History

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

  • [2024-07-27 19:49:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3744kb
  • [2024-07-27 19:49:42]
  • 提交

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 + mod) % 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3520kb

input:

2 1
1 2

output:

15

result:

ok single line: '15'

Test #2:

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

input:

5 10
26463 39326 86411 75307 85926

output:

806275469

result:

ok single line: '806275469'

Test #3:

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

input:

3 10000
329770536 859936159 696111818

output:

325223749

result:

ok single line: '325223749'

Test #4:

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

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'