Submission #5992815


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) % P, fact = fact * i % P;
    cout << ret * fact % P << endl;  
    return 0;
}

Submission Info

Submission Time
Task B - Removing Blocks
User vjudge3
Language C++14 (GCC 5.4.1)
Score 600
Code Size 578 Byte
Status
Exec Time 45 ms
Memory 2560 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
All 600 / 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 1 ms 256 KB
sample-02.txt 1 ms 256 KB
sample-03.txt 1 ms 256 KB
subtask01-01.txt 1 ms 256 KB
subtask01-02.txt 32 ms 2048 KB
subtask01-03.txt 25 ms 1664 KB
subtask01-04.txt 31 ms 2048 KB
subtask01-05.txt 11 ms 896 KB
subtask01-06.txt 18 ms 1152 KB
subtask01-07.txt 11 ms 768 KB
subtask01-08.txt 42 ms 2560 KB
subtask01-09.txt 42 ms 2560 KB
subtask01-10.txt 42 ms 2560 KB
subtask01-11.txt 42 ms 2560 KB
subtask01-12.txt 42 ms 2560 KB
subtask01-13.txt 45 ms 2560 KB