結果

問題 No.1509 Swap!!
ユーザー ks2mks2m
提出日時 2021-05-14 23:01:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 368 ms / 2,000 ms
コード長 1,034 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 77,540 KB
実行使用メモリ 57,732 KB
最終ジャッジ日時 2024-04-10 02:20:11
合計ジャッジ時間 13,161 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
49,948 KB
testcase_01 AC 53 ms
50,416 KB
testcase_02 AC 337 ms
57,588 KB
testcase_03 AC 344 ms
57,496 KB
testcase_04 AC 334 ms
57,424 KB
testcase_05 AC 337 ms
57,480 KB
testcase_06 AC 315 ms
57,472 KB
testcase_07 AC 325 ms
57,344 KB
testcase_08 AC 313 ms
57,276 KB
testcase_09 AC 350 ms
57,456 KB
testcase_10 AC 333 ms
57,524 KB
testcase_11 AC 311 ms
56,632 KB
testcase_12 AC 309 ms
57,204 KB
testcase_13 AC 313 ms
57,296 KB
testcase_14 AC 305 ms
57,168 KB
testcase_15 AC 287 ms
57,252 KB
testcase_16 AC 310 ms
57,200 KB
testcase_17 AC 288 ms
57,064 KB
testcase_18 AC 305 ms
57,292 KB
testcase_19 AC 312 ms
57,160 KB
testcase_20 AC 297 ms
57,148 KB
testcase_21 AC 311 ms
57,244 KB
testcase_22 AC 296 ms
57,416 KB
testcase_23 AC 299 ms
57,464 KB
testcase_24 AC 368 ms
57,448 KB
testcase_25 AC 354 ms
57,604 KB
testcase_26 AC 354 ms
57,664 KB
testcase_27 AC 278 ms
57,732 KB
testcase_28 AC 284 ms
57,580 KB
testcase_29 AC 289 ms
57,680 KB
testcase_30 AC 298 ms
57,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		PrintWriter pw = new PrintWriter(System.out);
		for (int z = 0; z < t; z++) {
			String[] sa = br.readLine().split(" ");
			long n = Long.parseLong(sa[0]);
			long a = Long.parseLong(sa[1]);
			long b = Long.parseLong(sa[2]);

			if (solve(n, Math.min(a, b), Math.max(a, b))) {
				pw.println("YES");
			} else {
				pw.println("NO");
			}
		}
		pw.flush();
		br.close();
	}

	static boolean solve(long n, long a, long b) {
		if (a == 1) {
			return true;
		}
		if (b % a == 0) {
			return false;
		}
		if (a * 2 > n) {
			return false;
		}
		long d = n - b;
		if (d < a - 1) {
			return false;
		}
		if (gcd(a, b) != 1) {
			return false;
		}
		return true;
	}

	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}
0