結果

問題 No.1509 Swap!!
ユーザー ks2mks2m
提出日時 2021-05-14 23:01:20
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 1,034 bytes
コンパイル時間 2,073 ms
使用メモリ 50,132 KB
最終ジャッジ日時 2022-11-25 21:05:36
合計ジャッジ時間 12,461 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 48 ms
39,704 KB
testcase_01 AC 56 ms
39,896 KB
testcase_02 AC 324 ms
46,640 KB
testcase_03 AC 331 ms
46,268 KB
testcase_04 AC 307 ms
47,096 KB
testcase_05 AC 312 ms
47,844 KB
testcase_06 AC 306 ms
48,504 KB
testcase_07 AC 319 ms
46,520 KB
testcase_08 AC 325 ms
47,008 KB
testcase_09 AC 301 ms
49,996 KB
testcase_10 AC 315 ms
47,780 KB
testcase_11 AC 292 ms
47,684 KB
testcase_12 AC 294 ms
47,860 KB
testcase_13 AC 289 ms
47,356 KB
testcase_14 AC 321 ms
48,080 KB
testcase_15 AC 281 ms
49,848 KB
testcase_16 AC 280 ms
49,660 KB
testcase_17 AC 291 ms
50,032 KB
testcase_18 AC 266 ms
50,132 KB
testcase_19 AC 317 ms
48,088 KB
testcase_20 AC 292 ms
47,432 KB
testcase_21 AC 285 ms
47,612 KB
testcase_22 AC 284 ms
47,828 KB
testcase_23 AC 313 ms
48,084 KB
testcase_24 AC 333 ms
48,260 KB
testcase_25 AC 342 ms
47,860 KB
testcase_26 AC 323 ms
47,880 KB
testcase_27 AC 263 ms
48,492 KB
testcase_28 AC 243 ms
49,920 KB
testcase_29 AC 246 ms
47,656 KB
testcase_30 AC 290 ms
49,744 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