結果

問題 No.793 うし数列 2
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-01-22 13:51:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 291 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,520 KB
実行使用メモリ 15,292 KB
最終ジャッジ日時 2023-09-22 07:59:21
合計ジャッジ時間 3,144 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,268 KB
testcase_01 AC 80 ms
15,036 KB
testcase_02 AC 82 ms
15,188 KB
testcase_03 AC 84 ms
15,100 KB
testcase_04 AC 83 ms
15,100 KB
testcase_05 AC 85 ms
15,280 KB
testcase_06 AC 80 ms
15,176 KB
testcase_07 AC 82 ms
15,144 KB
testcase_08 AC 83 ms
15,028 KB
testcase_09 AC 84 ms
15,140 KB
testcase_10 AC 81 ms
15,276 KB
testcase_11 AC 81 ms
15,096 KB
testcase_12 AC 80 ms
15,272 KB
testcase_13 AC 81 ms
15,208 KB
testcase_14 AC 80 ms
15,104 KB
testcase_15 AC 83 ms
15,148 KB
testcase_16 AC 81 ms
15,120 KB
testcase_17 AC 80 ms
15,028 KB
testcase_18 AC 81 ms
15,292 KB
testcase_19 AC 82 ms
15,080 KB
testcase_20 AC 82 ms
15,096 KB
testcase_21 AC 82 ms
15,120 KB
testcase_22 AC 82 ms
15,236 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def mod_pow(n,e,m)
  return 1 if e.zero?
  return n * mod_pow(n, e - 1, m) % m if e.odd?
  mod_pow(n, e / 2, m) ** 2 % m
end
def mod_inv(n,m)
  mod_pow(n, m - 2, m)
end

MOD = 10 ** 9 + 7
N = gets.to_i

ans = mod_pow(10, N, MOD) + 3 * (mod_pow(10,N,MOD) - 1) * mod_inv(9,MOD)
puts ans % MOD
0