結果
| 問題 | No.673 カブトムシ |
| コンテスト | |
| ユーザー |
rutilicus
|
| 提出日時 | 2020-12-27 14:27:47 |
| 言語 | Kotlin (2.3.20) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 966 bytes |
| 記録 | |
| コンパイル時間 | 8,094 ms |
| コンパイル使用メモリ | 446,060 KB |
| 最終ジャッジ日時 | 2026-04-17 14:29:25 |
| 合計ジャッジ時間 | 8,753 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Main.kt:11:17: error: 'fun StringBuilder.appendln(value: Long): StringBuilder' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
builder.appendln((b % mod) * (d % mod) % mod)
^^^^^^^^
Main.kt:16:17: error: 'fun StringBuilder.appendln(value: Long): StringBuilder' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
builder.appendln(ans)
^^^^^^^^
ソースコード
fun main() {
val builder = StringBuilder()
// modきらい
// ほかの解答コード写経したけど何をしているのか全然わからない……
val mod = 1000000007L
val (b, c, d) = readInputLine().split(" ").map { it.toLong() }
if (c % mod == 1L) {
builder.appendln((b % mod) * (d % mod) % mod)
} else {
val t1 = (b % mod) * (c % mod) % mod
val t2 = (mod - t1) % mod * pow((c - 1L) % mod, mod - 2L, mod) % mod
val ans = ((t1 - t2 + mod) % mod * pow(c % mod, d - 1L, mod) % mod + t2) % mod
builder.appendln(ans)
}
print(builder.toString())
}
fun readInputLine(): String {
return readLine()!!
}
fun pow(x: Long, n: Long, mod: Long): Long {
var ret = 1L
var base = x
var nTmp = n
while (nTmp != 0L) {
if (nTmp % 2L != 0L) {
ret = ret * base % mod
}
base = base * base % mod
nTmp /= 2L
}
return ret
}
rutilicus