結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー ks2mks2m
提出日時 2021-10-29 21:30:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 2,434 ms
コンパイル使用メモリ 79,352 KB
実行使用メモリ 41,996 KB
最終ジャッジ日時 2024-04-16 14:10:12
合計ジャッジ時間 10,989 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,516 KB
testcase_01 AC 135 ms
41,716 KB
testcase_02 AC 114 ms
41,696 KB
testcase_03 AC 130 ms
41,356 KB
testcase_04 AC 148 ms
41,720 KB
testcase_05 AC 141 ms
41,468 KB
testcase_06 AC 138 ms
41,316 KB
testcase_07 AC 134 ms
41,288 KB
testcase_08 AC 151 ms
41,528 KB
testcase_09 AC 122 ms
40,120 KB
testcase_10 AC 163 ms
41,616 KB
testcase_11 AC 130 ms
41,276 KB
testcase_12 AC 131 ms
41,728 KB
testcase_13 AC 132 ms
41,760 KB
testcase_14 AC 131 ms
41,320 KB
testcase_15 AC 180 ms
41,652 KB
testcase_16 AC 152 ms
41,732 KB
testcase_17 AC 175 ms
41,836 KB
testcase_18 AC 177 ms
41,928 KB
testcase_19 AC 160 ms
41,928 KB
testcase_20 AC 161 ms
41,700 KB
testcase_21 AC 179 ms
41,348 KB
testcase_22 AC 157 ms
41,616 KB
testcase_23 AC 155 ms
41,876 KB
testcase_24 AC 134 ms
41,552 KB
testcase_25 AC 174 ms
41,764 KB
testcase_26 AC 164 ms
41,792 KB
testcase_27 AC 133 ms
41,424 KB
testcase_28 AC 170 ms
41,976 KB
testcase_29 AC 173 ms
41,996 KB
testcase_30 AC 176 ms
41,508 KB
testcase_31 AC 177 ms
41,776 KB
testcase_32 AC 162 ms
41,964 KB
testcase_33 AC 134 ms
41,628 KB
testcase_34 AC 115 ms
40,168 KB
testcase_35 AC 125 ms
41,500 KB
testcase_36 AC 179 ms
41,788 KB
testcase_37 AC 127 ms
41,348 KB
testcase_38 AC 129 ms
41,064 KB
testcase_39 AC 127 ms
41,864 KB
testcase_40 AC 126 ms
41,360 KB
testcase_41 AC 115 ms
41,276 KB
testcase_42 AC 131 ms
41,264 KB
testcase_43 AC 129 ms
41,460 KB
testcase_44 AC 130 ms
41,684 KB
testcase_45 AC 130 ms
41,288 KB
testcase_46 AC 127 ms
40,984 KB
testcase_47 AC 130 ms
41,744 KB
testcase_48 AC 129 ms
41,212 KB
testcase_49 AC 128 ms
41,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long a = sc.nextLong();
		long y = sc.nextLong();
		long b = sc.nextLong();
		sc.close();

		Map<Long, Integer> mx = bunkai(x);
		Map<Long, Integer> my = bunkai(y);
		for (long k : my.keySet()) {
			if (!mx.containsKey(k)) {
				System.out.println("No");
				return;
			}
			long vx = mx.get(k) * a;
			long vy = my.get(k) * b;
			if (vx < vy) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

	static Map<Long, Integer> bunkai(long n) {
		Map<Long, Integer> soinsu = new HashMap<>();
		int end = (int) Math.sqrt(n);
		long d = 2;
		while (n > 1) {
			if (n % d == 0) {
				n /= d;
				soinsu.put(d, soinsu.getOrDefault(d, 0) + 1);
				end = (int) Math.sqrt(n);
			} else {
				if (d > end) {
					d = n - 1;
				}
				d++;
			}
		}
		return soinsu;
	}
}
0