結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー TwinkleStar74
提出日時 2017-09-18 17:33:55
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 962 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,685 ms
コンパイル使用メモリ 82,000 KB
実行使用メモリ 44,840 KB
最終ジャッジ日時 2026-05-08 09:50:09
合計ジャッジ時間 3,351 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class No48 {

	public static void main(String[] args) throws IOException, NumberFormatException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int touzai = Integer.parseInt(br.readLine());
		int nanboku = Integer.parseInt(br.readLine());
		int zenshin = Integer.parseInt(br.readLine());
		
		int x = Calculation.calc(touzai,zenshin);
		int y = Calculation.calc(nanboku,zenshin);
		
		System.out.println( x + y + Calculation.direction(touzai,nanboku));
	}
	
	
	public static class Calculation{
	
		public static int calc(int x, int y){
			if (Math.abs(x)%y == 0) return (Math.abs(x)/y); //Math.abs(x)はxの絶対値
			else return (Math.abs(x)/y) + 1;
		}
		
		public static int direction(int x, int y){
			if (x != 0 && y < 0 ) return 2;
			if (x != 0 && 0 <= y) return 1;
			if (x == 0 && y <0) return 2;
			else return 0;
		}
	}
}
0