結果
問題 | No.48 ロボットの操縦 |
ユーザー |
|
提出日時 | 2016-09-15 15:49:34 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,530 ms / 5,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 2,984 ms |
コンパイル使用メモリ | 74,512 KB |
実行使用メモリ | 41,676 KB |
最終ジャッジ日時 | 2024-11-21 18:54:39 |
合計ジャッジ時間 | 8,158 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
import java.util.Scanner; public class No048 { public static void main(String args[]){ int x = 0; int y = 0; int distance = 0; int go = 0; int turn = 0; Scanner sc = new Scanner(System.in); x = sc.nextInt(); y = sc.nextInt(); go = sc.nextInt(); //回頭に要する行為判定 if(0<y && x==0){ turn = 0; }else if(y==0 && x<0){ turn = 1; }else if(0<y){ turn = 1; }else if(y<0){ turn = 2; y=y*-1; } if(y!=0){ while(true){ y=y-go; turn++; if(y<=0){ break; } } } if(x<0){x=x*-1;} if(x!=0){ while(true){ x=x-go; turn++; if(x<=0){ break; } } } System.out.println(turn); } }