結果

問題 No.673 カブトムシ
ユーザー simansiman
提出日時 2021-12-16 01:44:20
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 409 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 11,336 KB
実行使用メモリ 15,344 KB
最終ジャッジ日時 2023-10-01 04:22:06
合計ジャッジ時間 3,641 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 82 ms
15,228 KB
testcase_03 AC 84 ms
15,144 KB
testcase_04 AC 82 ms
15,076 KB
testcase_05 AC 84 ms
15,152 KB
testcase_06 AC 83 ms
15,124 KB
testcase_07 AC 86 ms
15,112 KB
testcase_08 AC 83 ms
15,248 KB
testcase_09 AC 82 ms
15,080 KB
testcase_10 AC 82 ms
15,244 KB
testcase_11 AC 83 ms
15,332 KB
testcase_12 AC 82 ms
15,128 KB
testcase_13 AC 84 ms
15,120 KB
testcase_14 AC 84 ms
15,080 KB
testcase_15 AC 83 ms
15,344 KB
testcase_16 AC 87 ms
15,112 KB
testcase_17 AC 83 ms
15,064 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Integer
  def mod_pow(n, mod)
    x = self
    res = 1

    while n > 0
      res = res * x % mod if n[0] == 1
      x = x * x % mod
      n >>= 1
    end

    res
  end

  def mod_inverse(mod)
    mod_pow(mod - 2, mod)
  end
end

B, C, D = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7

S = if C == 1
      C * D
    else
      C * (C.pow(D, MOD) - 1) * (C - 1).mod_inverse(MOD)
    end

puts (B * S) % MOD
0