結果

問題 No.741 AscNumber(Easy)
ユーザー koi_kotyakoi_kotya
提出日時 2018-10-05 21:54:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 852 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 11,304 KB
実行使用メモリ 30,856 KB
最終ジャッジ日時 2023-08-02 17:03:57
合計ジャッジ時間 16,389 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,240 KB
testcase_01 AC 82 ms
15,112 KB
testcase_02 AC 81 ms
15,212 KB
testcase_03 AC 80 ms
15,280 KB
testcase_04 AC 81 ms
15,048 KB
testcase_05 AC 81 ms
15,268 KB
testcase_06 AC 81 ms
15,120 KB
testcase_07 AC 81 ms
15,192 KB
testcase_08 AC 79 ms
15,016 KB
testcase_09 AC 81 ms
15,256 KB
testcase_10 AC 81 ms
15,196 KB
testcase_11 AC 81 ms
15,144 KB
testcase_12 AC 83 ms
15,100 KB
testcase_13 AC 81 ms
15,224 KB
testcase_14 AC 82 ms
15,144 KB
testcase_15 AC 81 ms
15,096 KB
testcase_16 AC 80 ms
15,304 KB
testcase_17 AC 80 ms
15,108 KB
testcase_18 AC 80 ms
15,040 KB
testcase_19 AC 80 ms
15,280 KB
testcase_20 AC 81 ms
15,168 KB
testcase_21 AC 80 ms
15,032 KB
testcase_22 AC 83 ms
15,104 KB
testcase_23 AC 83 ms
15,032 KB
testcase_24 AC 82 ms
15,276 KB
testcase_25 AC 83 ms
15,220 KB
testcase_26 AC 84 ms
15,024 KB
testcase_27 AC 82 ms
15,056 KB
testcase_28 AC 80 ms
15,108 KB
testcase_29 AC 82 ms
15,268 KB
testcase_30 AC 83 ms
15,272 KB
testcase_31 AC 83 ms
15,032 KB
testcase_32 AC 82 ms
15,144 KB
testcase_33 AC 80 ms
15,100 KB
testcase_34 AC 80 ms
15,040 KB
testcase_35 AC 790 ms
30,124 KB
testcase_36 AC 401 ms
21,872 KB
testcase_37 AC 447 ms
22,796 KB
testcase_38 AC 443 ms
22,912 KB
testcase_39 AC 386 ms
21,788 KB
testcase_40 AC 501 ms
24,004 KB
testcase_41 AC 738 ms
28,808 KB
testcase_42 AC 434 ms
22,636 KB
testcase_43 AC 337 ms
20,528 KB
testcase_44 AC 608 ms
25,788 KB
testcase_45 AC 646 ms
26,816 KB
testcase_46 AC 767 ms
29,504 KB
testcase_47 AC 195 ms
17,816 KB
testcase_48 AC 763 ms
29,588 KB
testcase_49 AC 657 ms
27,212 KB
testcase_50 AC 160 ms
16,928 KB
testcase_51 AC 350 ms
20,608 KB
testcase_52 AC 852 ms
30,856 KB
testcase_53 AC 845 ms
30,828 KB
testcase_54 AC 828 ms
30,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
ans = 1
$mod = 10**9+7

def pow(a,b)
  if b == 1
    a
  elsif b%2 == 0
    (pow(a,b/2)**2)%$mod
  else
    (a*pow(a,b/2)**2)%$mod
  end
end

fact = Array.new(n+10,1)
for i in 2..n+9
  fact[i] = (fact[i-1]*i)%$mod
end

fact_inv = Array.new(n+10,1)
fact_inv[n+9] = pow(fact[n+9],$mod-2)
(n+9).downto(1) do |i|
  fact_inv[i-1] = (fact_inv[i]*i)%$mod
end

for i in 1..n
  ans += (fact[i+8]*fact_inv[i]*fact_inv[8])%$mod
  ans %= $mod
end

puts ans
0