結果

問題 No.797 Noelちゃんとピラミッド
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-01-25 08:39:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 1,305 ms
コンパイル使用メモリ 59,300 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 15:53:47
合計ジャッジ時間 6,039 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 107 ms
4,380 KB
testcase_04 AC 107 ms
4,380 KB
testcase_05 AC 108 ms
4,376 KB
testcase_06 AC 108 ms
4,380 KB
testcase_07 AC 108 ms
4,380 KB
testcase_08 AC 107 ms
4,380 KB
testcase_09 AC 107 ms
4,376 KB
testcase_10 AC 107 ms
4,376 KB
testcase_11 AC 107 ms
4,380 KB
testcase_12 AC 108 ms
4,384 KB
testcase_13 AC 108 ms
4,384 KB
testcase_14 AC 107 ms
4,380 KB
testcase_15 AC 108 ms
4,380 KB
testcase_16 AC 108 ms
4,376 KB
testcase_17 AC 107 ms
4,376 KB
testcase_18 AC 107 ms
4,376 KB
testcase_19 AC 107 ms
4,376 KB
testcase_20 AC 108 ms
4,380 KB
testcase_21 AC 107 ms
4,376 KB
testcase_22 AC 107 ms
4,380 KB
testcase_23 AC 77 ms
4,376 KB
testcase_24 AC 25 ms
4,376 KB
testcase_25 AC 65 ms
4,380 KB
testcase_26 AC 62 ms
4,376 KB
testcase_27 AC 105 ms
4,376 KB
testcase_28 AC 95 ms
4,376 KB
testcase_29 AC 15 ms
4,376 KB
testcase_30 AC 24 ms
4,380 KB
testcase_31 AC 77 ms
4,376 KB
testcase_32 AC 33 ms
4,380 KB
testcase_33 AC 64 ms
4,376 KB
testcase_34 AC 45 ms
4,376 KB
testcase_35 AC 107 ms
4,376 KB
testcase_36 AC 13 ms
4,380 KB
testcase_37 AC 94 ms
4,376 KB
testcase_38 AC 99 ms
4,376 KB
testcase_39 AC 63 ms
4,376 KB
testcase_40 AC 13 ms
4,376 KB
testcase_41 AC 19 ms
4,380 KB
testcase_42 AC 61 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 2 ms
4,376 KB
testcase_60 AC 1 ms
4,380 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;

ll MOD = 1e9 + 7;

/* a^{-1} mod m */
ll inv_mod( ll a, ll m = MOD )
{
  ll b, x, u, q, abs_m, tmp; 

  abs_m = ( m < 0 ) ? -m : m;
  b = m; x = 1; u = 0; 
  while ( b > 0 ) {
    q = a / b; 
    tmp = u; u = x - q * u; x = tmp;
    tmp = b; b = a - q * b; a = tmp;
  }

  return ( x < 0 ) ? abs_m + x : x;
}

ll fact[100010];

ll nCr(int n,int r)
{
	return fact[n] * inv_mod(fact[r]) % MOD * inv_mod(fact[n - r]) % MOD;
}

int N;

int main()
{
	cin >> N;
	fact[0] = 1;
	for(int i = 1;i <= N;i++)
	{
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	ll a;
	ll result = 0;
	for(int i = 0;i < N;i++)
	{
		cin >> a;
		result = (result + a * nCr(N - 1,i)) % MOD;
	}

	cout << result << endl;
	return 0;
}
0