結果
問題 |
No.797 Noelちゃんとピラミッド
|
ユーザー |
![]() |
提出日時 | 2019-03-15 22:31:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 597 bytes |
コンパイル時間 | 1,580 ms |
コンパイル使用メモリ | 166,632 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 21:10:25 |
合計ジャッジ時間 | 9,866 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 WA * 10 RE * 48 |
ソースコード
#include <bits/stdc++.h> using namespace std; long product_n2k(long n,long k){ if (n == 0){ return 1; } else if (n == k) { return n; }else { return n * product_n2k(n - 1, k); } } long bi_coefficient(long n, long k){ if (k == 0) return 1; else return product_n2k(n, n - k + 1) / product_n2k(k, 1); } int main (){ long long N,x,y; long long ans=0; cin >> N; for(long long i=0;i<N;i++){ cin >> y; x=bi_coefficient(N-1,i); ans += y*x; ans %= 1000000007; } cout << ans << endl; }