Submission #5992809


Source Code Expand

Copy
#include <bits/stdc++.h>
#define N 100010
#define P 1000000007
using namespace std;

int n;
long long a[N], inv[N], sum[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sum[0] = 0, inv[1] = 1;
    for (int i = 1; i <= n; ++i) {
        if (i > 1) inv[i] = (P - P / i) * inv[P % i] % P;
        sum[i] = (sum[i - 1] + inv[i]) % P;
    }
    long long ret = 0, fact = 1;
    for (int i = 1; i <= n; ++i) 
        ret = (ret + (sum[i] + sum[n - i + 1] - 1) * a[i] % P, fact = fact * i % P;
    cout << ret * fact % P << endl;  
    return 0;
}

Submission Info

Submission Time
Task B - Removing Blocks
User vjudge1
Language C++14 (GCC 5.4.1)
Score 0
Code Size 573 Byte
Status

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:83: error: expected ‘)’ before ‘;’ token
         ret = (ret + (sum[i] + sum[n - i + 1] - 1) * a[i] % P, fact = fact * i % P;
                                                                                   ^