結果
| 問題 |
No.48 ロボットの操縦
|
| コンテスト | |
| ユーザー |
rutilicus
|
| 提出日時 | 2020-08-30 22:00:46 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 312 ms / 5,000 ms |
| コード長 | 612 bytes |
| コンパイル時間 | 11,791 ms |
| コンパイル使用メモリ | 431,424 KB |
| 実行使用メモリ | 51,120 KB |
| 最終ジャッジ日時 | 2024-11-15 15:36:10 |
| 合計ジャッジ時間 | 21,108 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
コンパイルメッセージ
Main.kt:11:17: 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(0)
^
Main.kt:13:17: 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((abs(y) + l - 1) / l + if (y < 0) 2 else 0)
^
Main.kt:15:17: 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((abs(x) + l - 1) / l + 1)
^
Main.kt:17:17: 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((abs(y) + l - 1) / l + (abs(x) + l - 1) / l + 1 + if (y < 0) 1 else 0)
^
ソースコード
import kotlin.math.abs
fun main() {
val builder = StringBuilder()
val x = readInputLine().toInt()
val y = readInputLine().toInt()
val l = readInputLine().toInt()
if (x == 0 && y == 0) {
builder.appendln(0)
} else if (x == 0) {
builder.appendln((abs(y) + l - 1) / l + if (y < 0) 2 else 0)
} else if (y == 0) {
builder.appendln((abs(x) + l - 1) / l + 1)
} else {
builder.appendln((abs(y) + l - 1) / l + (abs(x) + l - 1) / l + 1 + if (y < 0) 1 else 0)
}
print(builder.toString())
}
fun readInputLine(): String {
return readLine()!!
}
rutilicus