結果
問題 | No.48 ロボットの操縦 |
ユーザー |
|
提出日時 | 2017-09-18 17:33:55 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 55 ms / 5,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 2,280 ms |
コンパイル使用メモリ | 76,124 KB |
実行使用メモリ | 37,248 KB |
最終ジャッジ日時 | 2024-11-08 02:34:13 |
合計ジャッジ時間 | 4,354 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
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;}}}