結果
| 問題 |
No.673 カブトムシ
|
| コンテスト | |
| ユーザー |
rutilicus
|
| 提出日時 | 2020-12-27 14:19:45 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 954 bytes |
| コンパイル時間 | 13,571 ms |
| コンパイル使用メモリ | 435,508 KB |
| 実行使用メモリ | 56,944 KB |
| 最終ジャッジ日時 | 2024-10-01 12:52:25 |
| 合計ジャッジ時間 | 20,019 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 WA * 1 |
コンパイルメッセージ
Main.kt:11:17: warning: 'appendln(Long): kotlin.text.StringBuilder /* = java.lang.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: warning: 'appendln(Long): kotlin.text.StringBuilder /* = java.lang.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 == 1L) {
builder.appendln((b % mod) * (d % mod) % mod)
} else {
val t1 = (b % mod) * (c % mod) % mod
val t2 = (mod - t1) * 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