結果

問題 No.797 Noelちゃんとピラミッド
ユーザー ugis_prog
提出日時 2019-03-15 22:42:16
言語 C++14
(gcc 8.2.0)
結果
WA   .
実行時間 -
コード長 800 Byte
コンパイル時間 484 ms
使用メモリ 3,668 KB
最終ジャッジ日時 2019-05-07 13:41:20

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt AC 3 ms
1,500 KB
002sample.txt AC 4 ms
1,496 KB
003sample.txt AC 3 ms
1,496 KB
LEARGE_case1.txt WA -
LEARGE_case2.txt WA -
LEARGE_case3.txt WA -
LEARGE_case4.txt WA -
LEARGE_case5.txt WA -
LEARGE_case6.txt WA -
LEARGE_case7.txt WA -
LEARGE_case8.txt WA -
LEARGE_case9.txt WA -
LEARGE_case10.txt WA -
LEARGE_case11.txt WA -
LEARGE_case12.txt WA -
LEARGE_case13.txt WA -
LEARGE_case14.txt WA -
LEARGE_case15.txt WA -
LEARGE_case16.txt WA -
LEARGE_case17.txt WA -
LEARGE_case18.txt WA -
LEARGE_case19.txt WA -
LEARGE_case20.txt WA -
RANDOM_case1.txt WA -
RANDOM_case2.txt WA -
RANDOM_case3.txt WA -
RANDOM_case4.txt WA -
RANDOM_case5.txt WA -
RANDOM_case6.txt WA -
RANDOM_case7.txt WA -
RANDOM_case8.txt WA -
RANDOM_case9.txt WA -
RANDOM_case10.txt WA -
RANDOM_case11.txt WA -
RANDOM_case12.txt WA -
RANDOM_case13.txt WA -
RANDOM_case14.txt WA -
RANDOM_case15.txt WA -
RANDOM_case16.txt WA -
RANDOM_case17.txt WA -
RANDOM_case18.txt WA -
RANDOM_case19.txt WA -
RANDOM_case20.txt WA -
SMALL_case1.txt WA -
SMALL_case2.txt WA -
SMALL_case3.txt WA -
SMALL_case4.txt WA -
SMALL_case5.txt WA -
SMALL_case6.txt WA -
SMALL_case7.txt WA -
SMALL_case8.txt WA -
SMALL_case9.txt WA -
SMALL_case10.txt WA -
SMALL_case11.txt WA -
SMALL_case12.txt WA -
SMALL_case13.txt WA -
SMALL_case14.txt WA -
SMALL_case15.txt WA -
SMALL_case16.txt WA -
SMALL_case17.txt WA -
SMALL_case18.txt WA -
SMALL_case19.txt WA -
SMALL_case20.txt WA -
テストケース一括ダウンロード

ソースコード

diff #
#include<iostream>
#include<vector>
#include<queue>
#include<string>
using namespace std;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

#define MOD 1000000007
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    vector<long long> factorial(N,1),nCr(N);
    for(int i=1;i<N;i++) factorial[i] = (factorial[i-1]*i) % MOD;
    for(int i=0;i<N;i++) {
        nCr[i] = factorial[N-1] * modinv(factorial[N-1-i],MOD) % MOD * modinv(factorial[i],MOD) % MOD;
    } 

    int ans = 0;
    for(int i=0;i<N;i++) ans += nCr[i]*A[i] % MOD;

    cout << ans;
}
0