結果
| 問題 | No.797 Noelちゃんとピラミッド |
| コンテスト | |
| ユーザー |
urutom
|
| 提出日時 | 2019-04-04 01:23:01 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 388 bytes |
| 記録 | |
| コンパイル時間 | 237 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 130,284 KB |
| 最終ジャッジ日時 | 2024-12-23 17:15:47 |
| 合計ジャッジ時間 | 121,663 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 TLE * 38 |
コンパイルメッセージ
Main.rb:12: warning: assigned but unused variable - d Main.rb:12: warning: assigned but unused variable - y Syntax OK
ソースコード
M=10**9+7
def extended_euclid_algorithm(a,b)
d0,x0,y0,d1,x1,y1=a,1,0,b,0,1
until d1==0
q=d0/d1
d0,x0,y0,d1,x1,y1=d1,x1,y1,d0-q*d1,x0-q*x1,y0-q*y1
end
[d0,x0,y0]
end
def inverse(a)
d,x,y=extended_euclid_algorithm(a,M)
x%M
end
n=gets.to_i-1
a=gets.split.map(&:to_i)
ans=0
comb=1
a.each_with_index{|v,i|
ans=(ans+comb*v)%M
comb=comb*(n-i)*inverse(i+1)
}
puts ans%M
urutom