結果

問題 No.797 Noelちゃんとピラミッド
ユーザー urutomurutom
提出日時 2019-04-04 01:24:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 11,400 KB
実行使用メモリ 24,512 KB
最終ジャッジ日時 2023-08-25 10:48:15
合計ジャッジ時間 14,185 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,048 KB
testcase_01 AC 80 ms
15,012 KB
testcase_02 AC 80 ms
15,300 KB
testcase_03 AC 297 ms
24,156 KB
testcase_04 AC 296 ms
24,328 KB
testcase_05 AC 294 ms
24,412 KB
testcase_06 AC 294 ms
24,324 KB
testcase_07 AC 297 ms
24,480 KB
testcase_08 AC 299 ms
24,276 KB
testcase_09 AC 297 ms
24,436 KB
testcase_10 AC 298 ms
24,412 KB
testcase_11 AC 297 ms
24,276 KB
testcase_12 AC 294 ms
24,164 KB
testcase_13 AC 295 ms
24,228 KB
testcase_14 AC 303 ms
24,304 KB
testcase_15 AC 295 ms
24,276 KB
testcase_16 AC 297 ms
24,472 KB
testcase_17 AC 297 ms
24,188 KB
testcase_18 AC 299 ms
24,448 KB
testcase_19 AC 295 ms
24,184 KB
testcase_20 AC 296 ms
24,468 KB
testcase_21 AC 296 ms
24,512 KB
testcase_22 AC 296 ms
24,488 KB
testcase_23 AC 237 ms
20,592 KB
testcase_24 AC 126 ms
16,340 KB
testcase_25 AC 206 ms
20,344 KB
testcase_26 AC 200 ms
20,128 KB
testcase_27 AC 291 ms
24,368 KB
testcase_28 AC 272 ms
21,360 KB
testcase_29 AC 106 ms
16,036 KB
testcase_30 AC 123 ms
16,528 KB
testcase_31 AC 237 ms
20,624 KB
testcase_32 AC 147 ms
17,528 KB
testcase_33 AC 204 ms
20,304 KB
testcase_34 AC 166 ms
19,220 KB
testcase_35 AC 296 ms
24,296 KB
testcase_36 AC 102 ms
15,308 KB
testcase_37 AC 271 ms
21,128 KB
testcase_38 AC 278 ms
24,172 KB
testcase_39 AC 201 ms
20,208 KB
testcase_40 AC 101 ms
15,296 KB
testcase_41 AC 113 ms
16,196 KB
testcase_42 AC 197 ms
20,224 KB
testcase_43 AC 83 ms
15,248 KB
testcase_44 AC 83 ms
15,288 KB
testcase_45 AC 82 ms
15,248 KB
testcase_46 AC 82 ms
15,096 KB
testcase_47 AC 82 ms
15,216 KB
testcase_48 AC 84 ms
15,156 KB
testcase_49 AC 83 ms
15,288 KB
testcase_50 AC 83 ms
15,088 KB
testcase_51 AC 81 ms
15,280 KB
testcase_52 AC 81 ms
15,132 KB
testcase_53 AC 80 ms
15,240 KB
testcase_54 AC 81 ms
15,272 KB
testcase_55 AC 80 ms
15,020 KB
testcase_56 AC 81 ms
15,088 KB
testcase_57 AC 82 ms
15,220 KB
testcase_58 AC 82 ms
15,340 KB
testcase_59 AC 81 ms
14,992 KB
testcase_60 AC 81 ms
14,992 KB
testcase_61 AC 81 ms
15,268 KB
testcase_62 AC 81 ms
15,096 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:12: warning: assigned but unused variable - d
Main.rb:12: warning: assigned but unused variable - y
Syntax OK

ソースコード

diff #

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))%M
}

puts ans%M
0