結果

問題 No.396 クラス替え
ユーザー nCk_cvnCk_cv
提出日時 2016-08-28 01:36:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 410 ms / 1,000 ms
コード長 764 bytes
コンパイル時間 2,420 ms
コンパイル使用メモリ 74,316 KB
実行使用メモリ 41,588 KB
最終ジャッジ日時 2024-04-28 17:20:06
合計ジャッジ時間 6,236 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
41,380 KB
testcase_01 AC 139 ms
41,280 KB
testcase_02 AC 139 ms
41,344 KB
testcase_03 AC 138 ms
41,588 KB
testcase_04 AC 136 ms
41,132 KB
testcase_05 AC 135 ms
41,448 KB
testcase_06 AC 137 ms
40,980 KB
testcase_07 AC 151 ms
41,260 KB
testcase_08 AC 161 ms
41,292 KB
testcase_09 AC 410 ms
40,044 KB
testcase_10 AC 133 ms
41,156 KB
testcase_11 AC 141 ms
41,084 KB
testcase_12 AC 135 ms
41,404 KB
testcase_13 AC 136 ms
41,312 KB
testcase_14 AC 135 ms
41,276 KB
testcase_15 AC 137 ms
41,504 KB
testcase_16 AC 135 ms
41,072 KB
testcase_17 AC 129 ms
41,260 KB
testcase_18 AC 136 ms
41,112 KB
testcase_19 AC 116 ms
39,804 KB
権限があれば一括ダウンロードができます

ソースコード

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