結果

問題 No.1224 I hate Sqrt Inequality
ユーザー rutilicusrutilicus
提出日時 2020-09-12 11:27:37
言語 Kotlin
(1.9.23)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 788 bytes
コンパイル時間 12,031 ms
コンパイル使用メモリ 424,980 KB
実行使用メモリ 53,328 KB
最終ジャッジ日時 2023-08-30 19:36:01
合計ジャッジ時間 19,201 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 285 ms
52,984 KB
testcase_01 AC 286 ms
53,048 KB
testcase_02 AC 285 ms
53,028 KB
testcase_03 AC 285 ms
52,944 KB
testcase_04 AC 287 ms
52,984 KB
testcase_05 AC 288 ms
52,940 KB
testcase_06 AC 286 ms
53,160 KB
testcase_07 AC 1,771 ms
53,240 KB
testcase_08 AC 287 ms
53,024 KB
testcase_09 AC 286 ms
52,916 KB
testcase_10 AC 284 ms
53,032 KB
testcase_11 AC 292 ms
52,900 KB
testcase_12 AC 291 ms
53,004 KB
testcase_13 WA -
testcase_14 AC 285 ms
53,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:32: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")
            ^

ソースコード

diff #

import kotlin.math.max
import kotlin.math.sqrt

fun main() {
    val builder = StringBuilder()

    val (a, b) = readInputLine().split(" ").map { it.toLong() }

    var aTmp = a
    var bTmp = b

    for (i in LongRange(2L, sqrt(max(a, b).toDouble()).toLong() + 1L)) {
        if (bTmp == 1L) {
            break
        }
        if (i % 2L == 0L || i % 5L == 0L) {
            while (bTmp % i == 0L) {
                bTmp /= i
            }
            continue
        }
        while (bTmp % i == 0L) {
            if (aTmp % i != 0L) {
                println("Yes")
                return
            }
            bTmp /= i
            aTmp /= i
        }
    }

    builder.appendln("No")

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0