Submission #5992782


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] - 1) * a[i] % P + sum[n - i + 1] * a[i] % P) % P, fact = fact * i % P;
    cout << ret * fact % P << endl;  
    return 0;
}

Submission Info

Submission Time
Task B - Removing Blocks
User vjudge4
Language Bash (GNU bash v4.3.11)
Score 0
Code Size 589 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
All 0 / 600 sample-01.txt, sample-02.txt, sample-03.txt, sample-01.txt, sample-02.txt, sample-03.txt, subtask01-01.txt, subtask01-02.txt, subtask01-03.txt, subtask01-04.txt, subtask01-05.txt, subtask01-06.txt, subtask01-07.txt, subtask01-08.txt, subtask01-09.txt, subtask01-10.txt, subtask01-11.txt, subtask01-12.txt, subtask01-13.txt
Case Name Status Exec Time Memory
sample-01.txt
sample-02.txt
sample-03.txt
subtask01-01.txt
subtask01-02.txt
subtask01-03.txt
subtask01-04.txt
subtask01-05.txt
subtask01-06.txt
subtask01-07.txt
subtask01-08.txt
subtask01-09.txt
subtask01-10.txt
subtask01-11.txt
subtask01-12.txt
subtask01-13.txt