結果
| 問題 |
No.48 ロボットの操縦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-20 17:38:02 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,906 bytes |
| コンパイル時間 | 3,932 ms |
| コンパイル使用メモリ | 76,884 KB |
| 実行使用メモリ | 41,704 KB |
| 最終ジャッジ日時 | 2024-12-30 10:39:58 |
| 合計ジャッジ時間 | 13,288 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 6 |
ソースコード
import java.util.Scanner;
public class Robot {
static int x;
static int y;
static int l;
static int x1 = 0;
static int y1 = 0;
static int count = 0;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
x = scanner.nextInt();
y = scanner.nextInt();
l = scanner.nextInt();
x1 = 0;
y1 = 0;
//初期状態のまま進めない
if(y < 0){
//回転してx方向へ移動
moveX();
//回転して-y方向へ
count++;
while( (y1 -= l) > y){
count++;
}
if((y1 += l) != y){
count++;
}
}else if(y > 0){
//回転せずy方向へ
while( (y1 += l) < y){
count++;
}
if((y1 -= l) != y){
count++;
}
//回転してx方向へ移動
moveX();
}else{
//回転してx方向へ移動
moveX();
}
System.out.println(count);
}
static void moveX(){
if(x == 0){
return;
}
count++;
if(x<0){
while( (x1 -= l) > x){
count++;
}
if((x1 += l) != x){
count++;
}
}else if(x>0){
while( (x1 += l) > x){
count++;
}
if((x1 -= l) != x){
count++;
}
}
}
}