結果
| 問題 |
No.673 カブトムシ
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-12-16 01:56:57 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 2,000 ms |
| コード長 | 501 bytes |
| コンパイル時間 | 46 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-07-23 21:57:53 |
| 合計ジャッジ時間 | 2,607 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
コンパイルメッセージ
Syntax OK
ソースコード
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
def sum(a, r, n, mod)
return a % mod if n == 1
x = sum(a, r, n / 2, mod)
ret = (x + r.pow(n / 2, mod) * x) % mod
ret = (a + r * ret) % mod if n.odd?
ret
end
S = sum(C, C, D, MOD)
puts (B * S) % MOD
siman