結果
| 問題 |
No.1218 Something Like a Theorem
|
| ユーザー |
rutilicus
|
| 提出日時 | 2020-09-06 10:56:17 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 970 bytes |
| コンパイル時間 | 12,563 ms |
| コンパイル使用メモリ | 435,792 KB |
| 実行使用メモリ | 114,028 KB |
| 最終ジャッジ日時 | 2024-11-29 06:51:56 |
| 合計ジャッジ時間 | 22,341 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 TLE * 1 |
コンパイルメッセージ
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, 10000L)) {
val xPow = pow(x, n, mod)
if (xPow > zPow) {
break
}
for (y in LongRange(1L, 10000L)) {
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
}
rutilicus