結果
問題 | No.673 カブトムシ |
ユーザー |
![]() |
提出日時 | 2020-12-27 14:27:47 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 289 ms / 2,000 ms |
コード長 | 966 bytes |
コンパイル時間 | 14,734 ms |
コンパイル使用メモリ | 440,316 KB |
実行使用メモリ | 51,972 KB |
最終ジャッジ日時 | 2024-10-01 12:58:37 |
合計ジャッジ時間 | 18,221 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 |
コンパイルメッセージ
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 = 1000000007Lval (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) % modval t2 = (mod - t1) % mod * pow((c - 1L) % mod, mod - 2L, mod) % modval ans = ((t1 - t2 + mod) % mod * pow(c % mod, d - 1L, mod) % mod + t2) % modbuilder.appendln(ans)}print(builder.toString())}fun readInputLine(): String {return readLine()!!}fun pow(x: Long, n: Long, mod: Long): Long {var ret = 1Lvar base = xvar nTmp = nwhile (nTmp != 0L) {if (nTmp % 2L != 0L) {ret = ret * base % mod}base = base * base % modnTmp /= 2L}return ret}