結果

問題 No.797 Noelちゃんとピラミッド
ユーザー sinsincoscossinsincoscos
提出日時 2019-03-15 21:39:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 52,800 KB
実行使用メモリ 7,216 KB
最終ジャッジ日時 2023-09-14 13:11:54
合計ジャッジ時間 6,738 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,368 KB
testcase_01 AC 2 ms
5,356 KB
testcase_02 AC 2 ms
5,444 KB
testcase_03 AC 126 ms
6,936 KB
testcase_04 AC 126 ms
6,936 KB
testcase_05 AC 126 ms
6,980 KB
testcase_06 AC 126 ms
7,048 KB
testcase_07 AC 125 ms
7,124 KB
testcase_08 AC 126 ms
6,936 KB
testcase_09 AC 126 ms
7,048 KB
testcase_10 AC 126 ms
7,004 KB
testcase_11 AC 126 ms
6,996 KB
testcase_12 AC 125 ms
6,996 KB
testcase_13 AC 126 ms
6,936 KB
testcase_14 AC 125 ms
7,216 KB
testcase_15 AC 126 ms
6,912 KB
testcase_16 AC 126 ms
6,936 KB
testcase_17 AC 127 ms
7,008 KB
testcase_18 AC 124 ms
6,936 KB
testcase_19 AC 125 ms
7,000 KB
testcase_20 AC 125 ms
6,916 KB
testcase_21 AC 126 ms
6,936 KB
testcase_22 AC 125 ms
7,064 KB
testcase_23 AC 91 ms
6,616 KB
testcase_24 AC 30 ms
5,700 KB
testcase_25 AC 76 ms
6,328 KB
testcase_26 AC 72 ms
6,440 KB
testcase_27 AC 122 ms
6,872 KB
testcase_28 AC 111 ms
6,936 KB
testcase_29 AC 18 ms
5,560 KB
testcase_30 AC 28 ms
5,760 KB
testcase_31 AC 90 ms
6,544 KB
testcase_32 AC 39 ms
5,880 KB
testcase_33 AC 74 ms
6,264 KB
testcase_34 AC 53 ms
6,212 KB
testcase_35 AC 125 ms
7,064 KB
testcase_36 AC 15 ms
5,592 KB
testcase_37 AC 110 ms
6,736 KB
testcase_38 AC 115 ms
6,800 KB
testcase_39 AC 73 ms
6,252 KB
testcase_40 AC 15 ms
5,552 KB
testcase_41 AC 22 ms
5,688 KB
testcase_42 AC 71 ms
6,372 KB
testcase_43 AC 2 ms
5,356 KB
testcase_44 AC 3 ms
5,356 KB
testcase_45 AC 2 ms
5,432 KB
testcase_46 AC 2 ms
5,444 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,432 KB
testcase_49 AC 2 ms
5,372 KB
testcase_50 AC 2 ms
5,572 KB
testcase_51 AC 2 ms
5,388 KB
testcase_52 AC 2 ms
5,428 KB
testcase_53 AC 2 ms
5,392 KB
testcase_54 AC 2 ms
5,432 KB
testcase_55 AC 2 ms
5,364 KB
testcase_56 AC 2 ms
5,372 KB
testcase_57 AC 2 ms
5,492 KB
testcase_58 AC 2 ms
5,496 KB
testcase_59 AC 2 ms
5,504 KB
testcase_60 AC 2 ms
5,356 KB
testcase_61 AC 2 ms
5,376 KB
testcase_62 AC 2 ms
5,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;
ll A[100010],inf = 1e9+7;
int N;

ll func[300010] = {0};
ll inv[300010] = {0};

ll mult(ll n, ll m){
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}

void factorial(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			func[i] = 1;
			inv[i] = 1;
		}
		else{
			func[i] = (i*func[i-1])%inf;
			inv[i] = mult(func[i],inf-2);
		}
	}
}

ll comb(ll n,ll k){
	if(k==0 || n==k) return 1;
	else return (((func[n]*inv[k])%inf)*inv[n-k])%inf;
}


int main(){
    cin >> N;
    factorial(N);
    ll ans = 0;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        (ans += (comb(N-1,i-1)*A[i])%inf)%=inf;
    }
    cout << ans << endl;
}
0