結果

問題 No.48 ロボットの操縦
ユーザー S1hoS1ho
提出日時 2017-02-20 17:38:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,906 bytes
コンパイル時間 3,339 ms
コンパイル使用メモリ 74,072 KB
実行使用メモリ 57,676 KB
最終ジャッジ日時 2023-08-28 21:34:09
合計ジャッジ時間 11,685 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,972 KB
testcase_01 AC 123 ms
55,804 KB
testcase_02 WA -
testcase_03 AC 3,896 ms
55,640 KB
testcase_04 WA -
testcase_05 AC 124 ms
55,744 KB
testcase_06 AC 125 ms
55,760 KB
testcase_07 AC 131 ms
56,056 KB
testcase_08 WA -
testcase_09 AC 129 ms
55,692 KB
testcase_10 AC 126 ms
56,080 KB
testcase_11 AC 126 ms
55,712 KB
testcase_12 WA -
testcase_13 AC 126 ms
55,692 KB
testcase_14 WA -
testcase_15 AC 133 ms
55,704 KB
testcase_16 AC 125 ms
55,400 KB
testcase_17 AC 123 ms
55,832 KB
testcase_18 AC 126 ms
55,928 KB
testcase_19 AC 126 ms
55,804 KB
testcase_20 AC 124 ms
56,000 KB
testcase_21 AC 123 ms
55,740 KB
testcase_22 WA -
testcase_23 AC 125 ms
53,964 KB
testcase_24 AC 124 ms
55,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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++;
                }
                
            }
    } 
}
0