結果
問題 | No.816 Beautiful tuples |
ユーザー |
![]() |
提出日時 | 2020-09-13 08:39:32 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 294 ms / 1,500 ms |
コード長 | 726 bytes |
コンパイル時間 | 12,246 ms |
コンパイル使用メモリ | 434,132 KB |
実行使用メモリ | 55,036 KB |
最終ジャッジ日時 | 2024-06-11 15:37:27 |
合計ジャッジ時間 | 17,461 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
コンパイルメッセージ
Main.kt:26: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) ^
ソースコード
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 ((a + b) % c == 0 && c != a && c != b) { if ((a + c) % b == 0 && (b + c) % a == 0) { ans = c break } } val c2 = (a + b) / c if ((a + b) % c2 == 0 && c2 != a && c2 != b) { if ((a + c2) % b == 0 && (b + c2) % a == 0) { ans = c2 break } } } builder.appendln(ans) print(builder.toString()) } fun readInputLine(): String { return readLine()!! }