結果

問題 No.816 Beautiful tuples
ユーザー rutilicusrutilicus
提出日時 2020-09-13 08:37:00
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 556 bytes
コンパイル時間 15,982 ms
コンパイル使用メモリ 417,476 KB
実行使用メモリ 54,876 KB
最終ジャッジ日時 2023-09-02 08:40:30
合計ジャッジ時間 22,141 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 305 ms
52,892 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 302 ms
52,844 KB
testcase_08 AC 316 ms
52,956 KB
testcase_09 AC 312 ms
52,884 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 304 ms
53,144 KB
testcase_13 AC 305 ms
52,892 KB
testcase_14 AC 312 ms
52,732 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:22:13: warning: 'appendln(Int): 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)
            ^

ソースコード

diff #

import kotlin.math.sqrt

fun main() {
    val builder = StringBuilder()

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

    var ans = -1

    for (c in 1..sqrt((a + b).toDouble()).toInt() + 1) {
        if (c == a || c == b) {
            continue
        }
        if ((a + b) % c == 0) {
            if ((a + c) % b == 0 && (b + c) % a == 0) {
                ans = c
                break
            }
        }
    }

    builder.appendln(ans)

    print(builder.toString())
}

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