結果

問題 No.741 AscNumber(Easy)
ユーザー koi_kotyakoi_kotya
提出日時 2018-10-05 21:54:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 955 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 28,032 KB
最終ジャッジ日時 2024-04-20 17:12:04
合計ジャッジ時間 17,427 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
12,160 KB
testcase_01 AC 92 ms
12,160 KB
testcase_02 AC 89 ms
12,160 KB
testcase_03 AC 88 ms
12,160 KB
testcase_04 AC 87 ms
12,160 KB
testcase_05 AC 86 ms
12,288 KB
testcase_06 AC 92 ms
12,032 KB
testcase_07 AC 88 ms
12,032 KB
testcase_08 AC 89 ms
12,160 KB
testcase_09 AC 89 ms
12,160 KB
testcase_10 AC 89 ms
12,160 KB
testcase_11 AC 91 ms
12,288 KB
testcase_12 AC 89 ms
12,032 KB
testcase_13 AC 91 ms
12,288 KB
testcase_14 AC 89 ms
12,160 KB
testcase_15 AC 88 ms
12,288 KB
testcase_16 AC 87 ms
12,288 KB
testcase_17 AC 87 ms
12,160 KB
testcase_18 AC 90 ms
12,160 KB
testcase_19 AC 88 ms
12,160 KB
testcase_20 AC 89 ms
12,288 KB
testcase_21 AC 89 ms
12,160 KB
testcase_22 AC 89 ms
12,160 KB
testcase_23 AC 89 ms
12,032 KB
testcase_24 AC 87 ms
12,160 KB
testcase_25 AC 86 ms
12,288 KB
testcase_26 AC 92 ms
12,160 KB
testcase_27 AC 91 ms
12,288 KB
testcase_28 AC 90 ms
12,288 KB
testcase_29 AC 89 ms
12,288 KB
testcase_30 AC 89 ms
12,160 KB
testcase_31 AC 90 ms
12,288 KB
testcase_32 AC 88 ms
12,160 KB
testcase_33 AC 91 ms
12,160 KB
testcase_34 AC 91 ms
12,160 KB
testcase_35 AC 915 ms
27,392 KB
testcase_36 AC 449 ms
18,816 KB
testcase_37 AC 514 ms
19,968 KB
testcase_38 AC 509 ms
19,840 KB
testcase_39 AC 440 ms
18,816 KB
testcase_40 AC 568 ms
20,992 KB
testcase_41 AC 849 ms
25,856 KB
testcase_42 AC 485 ms
19,712 KB
testcase_43 AC 378 ms
17,664 KB
testcase_44 AC 673 ms
22,912 KB
testcase_45 AC 718 ms
23,808 KB
testcase_46 AC 871 ms
26,496 KB
testcase_47 AC 223 ms
14,464 KB
testcase_48 AC 870 ms
26,496 KB
testcase_49 AC 755 ms
24,192 KB
testcase_50 AC 178 ms
13,696 KB
testcase_51 AC 390 ms
17,792 KB
testcase_52 AC 955 ms
28,032 KB
testcase_53 AC 952 ms
28,032 KB
testcase_54 AC 940 ms
27,904 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