結果

問題 No.396 クラス替え
ユーザー nCk_cv
提出日時 2016-08-28 01:36:44
言語 Java
(openjdk 23)
結果
AC  
実行時間 377 ms / 1,000 ms
コード長 764 bytes
コンパイル時間 2,546 ms
コンパイル使用メモリ 75,108 KB
実行使用メモリ 41,280 KB
最終ジャッジ日時 2024-11-17 11:14:30
合計ジャッジ時間 5,550 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main {
		static int INF = 2 << 27;
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int M = sc.nextInt();
			int X = sc.nextInt();
			int Y = sc.nextInt();
			
			int now = 1;
			int ansX = -1;
			int ansY = -1;
			while(true) {
				if(now > N || (ansX != -1 && ansY != -1)) break;
				if(now + M > X && now <= X) {
					ansX = X - now + 1;
				}
				if(now + M > Y && now <= Y) {
					ansY = Y - now + 1;
				}
				now += M;
				if(now + M > X && now <= X) {
					ansX = now + M - X;
				}
				if(now + M > Y && now <= Y) {
					ansY = now + M - Y;
				}
				now += M;
			}
			if(ansX == ansY) System.out.println("YES");
			else System.out.println("NO");
		}

}
0