結果

問題 No.1081 和の和
ユーザー kenken714kenken714
提出日時 2020-06-20 16:29:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,340 bytes
コンパイル時間 2,849 ms
コンパイル使用メモリ 146,204 KB
実行使用メモリ 5,052 KB
最終ジャッジ日時 2023-09-16 17:35:44
合計ジャッジ時間 3,448 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,912 KB
testcase_01 AC 3 ms
4,976 KB
testcase_02 AC 4 ms
4,980 KB
testcase_03 AC 4 ms
4,856 KB
testcase_04 AC 4 ms
4,868 KB
testcase_05 AC 4 ms
5,040 KB
testcase_06 AC 3 ms
4,872 KB
testcase_07 AC 4 ms
4,956 KB
testcase_08 AC 4 ms
4,900 KB
testcase_09 AC 4 ms
5,052 KB
testcase_10 AC 4 ms
4,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll powmod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)res = res * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return res;
}
ll f[210000];
void cominit() {
    f[0] = 1;
    REP(i, 200000)f[i + 1] = f[i] * (i + 1) % MOD;
}

ll nCr(ll n, ll r) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

ll nPr(ll n, ll r) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return f[n] * powmod(f[n - r], MOD - 2) % MOD;
}

ll nHr(ll n, ll r) {
    if (n < r)return 0;
    if (n < 0 or r < 0)return 0;
    return nCr(n + r - 1, r);
}
int main() {
    cominit();
    ll n;
    cin >> n;
    vector<ll> s(n);
    REP(i, n){
        cin >> s[i];
    }
    ll ans = 0;
    REP(i, n){
        ans += s[i] * nCr(n - 1, i) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}
0