結果
| 問題 |
No.48 ロボットの操縦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-01 10:28:13 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 5,000 ms |
| コード長 | 1,254 bytes |
| コンパイル時間 | 4,223 ms |
| コンパイル使用メモリ | 80,056 KB |
| 実行使用メモリ | 51,280 KB |
| 最終ジャッジ日時 | 2025-02-01 10:28:22 |
| 合計ジャッジ時間 | 7,530 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
import java.io.*;
import java.util.regex.*;
class Process {
private int X;
private int Y;
private int L;
Process(int X, int Y, int L) {
this.X = X;
this.Y = Y;
this.L = L;
}
private int moveCount(int n) {
if(n < 0) {
n *= (-1);
}
return (int)Math.ceil((double)n / L);
}
int getResult() {
if((X == 0) && (Y >= 0)) {
return moveCount(Y);
}
int rotateCount = (Y >= 0) ? 1 : 2;
return (moveCount(X) + moveCount(Y) + rotateCount);
}
}
public class Main {
public static void main(String[] args) throws IOException {
var bufferedReader = new BufferedReader(new InputStreamReader(System.in));
var printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
// 入力
int X = Integer.parseInt(bufferedReader.readLine().trim());
int Y = Integer.parseInt(bufferedReader.readLine().trim());
int L = Integer.parseInt(bufferedReader.readLine().trim());
// 処理および出力
printWriter.println((new Process(X, Y, L)).getResult());
bufferedReader.close();
printWriter.close();
}
}