結果

問題 No.48 ロボットの操縦
ユーザー soujikisoujiki
提出日時 2015-04-27 15:49:25
言語 Java19
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 872 bytes
コンパイル時間 3,378 ms
コンパイル使用メモリ 74,948 KB
実行使用メモリ 56,368 KB
最終ジャッジ日時 2023-08-14 00:05:37
合計ジャッジ時間 7,614 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,884 KB
testcase_01 AC 121 ms
56,076 KB
testcase_02 AC 124 ms
56,352 KB
testcase_03 AC 121 ms
55,776 KB
testcase_04 AC 124 ms
56,128 KB
testcase_05 AC 120 ms
55,824 KB
testcase_06 AC 122 ms
55,884 KB
testcase_07 AC 122 ms
55,860 KB
testcase_08 AC 121 ms
55,892 KB
testcase_09 AC 121 ms
55,784 KB
testcase_10 AC 122 ms
56,096 KB
testcase_11 AC 121 ms
55,764 KB
testcase_12 AC 122 ms
55,936 KB
testcase_13 AC 125 ms
55,896 KB
testcase_14 AC 122 ms
55,880 KB
testcase_15 AC 121 ms
55,752 KB
testcase_16 AC 123 ms
56,368 KB
testcase_17 AC 122 ms
55,852 KB
testcase_18 AC 123 ms
55,616 KB
testcase_19 AC 122 ms
55,696 KB
testcase_20 AC 121 ms
55,836 KB
testcase_21 AC 123 ms
55,820 KB
testcase_22 AC 124 ms
55,656 KB
testcase_23 AC 121 ms
55,400 KB
testcase_24 AC 122 ms
55,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

	
import java.util.*;

public class Yukicoder_48{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int X = stdIn.nextInt();
		int Y = stdIn.nextInt();
		int L = stdIn.nextInt();
		int count = 0;

		if(X==0 && Y==0){
			System.out.println("0");
		}
		else{
			if(X>0){
				count++;
				int x = X/L;
				count += x;
				X = X - x*L;
				if(X!=0){
					count++;
				}
				X++;

			}
			else if(X<0){
				count++;
				X = (-1)*X;
				int x = X/L;
				count += x;
				X = X - x*L;
				if(X!=0){
					count++;
				}
				X++;
			}

			if(Y>0){
				int y = Y/L;
				count += y;
				Y = Y - y*L;
				if(Y!=0){
					count++;
				}
			}
			else if(Y<0){
				if(X==0){
					count++;
				}
				count++;
				Y = (-1)*Y;
				int y = Y/L;
				count += y;
				Y = Y - y*L;
				if(Y!=0){
					count++;
				}
			}

			System.out.println(count);

		}

	}
}
0