結果

問題 No.48 ロボットの操縦
ユーザー core123
提出日時 2019-04-16 16:51:55
言語 Java
(openjdk 23)
結果
AC  
実行時間 133 ms / 5,000 ms
コード長 1,110 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 78,676 KB
実行使用メモリ 54,252 KB
最終ジャッジ日時 2024-09-22 08:19:21
合計ジャッジ時間 6,335 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.stream.*;
import static java.lang.Math.*;
public class Main{
	public static void main(String... args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int l=sc.nextInt();
		int ans=0;
		if(x==0){
			if(y==0){
				put(0);
				return;
			}else if(y>0){
			}else{
				ans+=2;
			}
		}else if(x>0){
			if(y==0){
				ans+=1;
			}else if(y>0){
				ans+=1;
			}else{
				ans+=2;
			}
		}else{
			if(y==0){
				ans+=1;
			}else if(y>0){
				ans+=1;
			}else{
				ans+=2;
			}
		}
		ans+=x%l==0?abs(x/l):abs(x/l)+1;
		ans+=y%l==0?abs(y/l):abs(y/l)+1;
		put(ans);
	}
	
	public static void print(Object object){
        System.out.print(object);
    }
    public static void put(Object object) {
        System.out.println(object);
    }
    public static void put(){
        System.out.println();
    }
 
    public static void print(String format,Object... args){
        System.out.print(String.format(format,args));
    }
    public static void put(String format,Object... args) {
        System.out.println(String.format(format,args));
    }
}
0