結果
問題 | No.1218 Something Like a Theorem |
ユーザー | rutilicus |
提出日時 | 2020-09-06 10:59:26 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 345 ms / 2,000 ms |
コード長 | 974 bytes |
コンパイル時間 | 15,699 ms |
コンパイル使用メモリ | 422,868 KB |
実行使用メモリ | 53,140 KB |
最終ジャッジ日時 | 2023-08-19 13:40:37 |
合計ジャッジ時間 | 20,753 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 301 ms
53,140 KB |
testcase_01 | AC | 306 ms
52,624 KB |
testcase_02 | AC | 307 ms
52,944 KB |
testcase_03 | AC | 302 ms
52,904 KB |
testcase_04 | AC | 297 ms
52,812 KB |
testcase_05 | AC | 341 ms
52,928 KB |
testcase_06 | AC | 299 ms
52,884 KB |
testcase_07 | AC | 328 ms
52,904 KB |
testcase_08 | AC | 335 ms
52,968 KB |
testcase_09 | AC | 345 ms
53,024 KB |
testcase_10 | AC | 320 ms
53,008 KB |
testcase_11 | AC | 299 ms
52,924 KB |
testcase_12 | AC | 301 ms
52,684 KB |
testcase_13 | AC | 297 ms
52,804 KB |
testcase_14 | AC | 305 ms
52,852 KB |
testcase_15 | AC | 307 ms
52,536 KB |
testcase_16 | AC | 302 ms
52,556 KB |
testcase_17 | AC | 302 ms
52,824 KB |
コンパイルメッセージ
Main.kt:27:13: warning: 'appendln(String?): 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("No") ^
ソースコード
fun main() { val builder = StringBuilder() val mod = 1000000007L val (n, z) = readInputLine().split(" ").map { it.toLong() } val zPow = pow(z, n, mod) for (x in LongRange(1L, 1000000L)) { val xPow = pow(x, n, mod) if (xPow > zPow) { break } for (y in LongRange(1L, 1000000L)) { val yPow = pow(y, n, mod) if (xPow + yPow > zPow) { break } if (xPow + yPow == zPow) { println("Yes") return } } } builder.appendln("No") 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 }