結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー tentententen
提出日時 2022-08-09 08:25:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,752 bytes
コンパイル時間 3,412 ms
コンパイル使用メモリ 78,556 KB
実行使用メモリ 55,992 KB
最終ジャッジ日時 2023-10-19 19:34:49
合計ジャッジ時間 8,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,352 KB
testcase_01 AC 55 ms
53,340 KB
testcase_02 AC 55 ms
53,336 KB
testcase_03 AC 58 ms
53,348 KB
testcase_04 AC 80 ms
54,060 KB
testcase_05 AC 68 ms
54,176 KB
testcase_06 AC 57 ms
53,348 KB
testcase_07 AC 55 ms
53,348 KB
testcase_08 AC 66 ms
54,052 KB
testcase_09 AC 56 ms
53,348 KB
testcase_10 AC 68 ms
54,052 KB
testcase_11 AC 55 ms
53,344 KB
testcase_12 AC 58 ms
53,336 KB
testcase_13 AC 55 ms
52,420 KB
testcase_14 AC 55 ms
51,444 KB
testcase_15 AC 95 ms
55,056 KB
testcase_16 AC 69 ms
54,052 KB
testcase_17 AC 96 ms
55,176 KB
testcase_18 AC 94 ms
54,948 KB
testcase_19 AC 86 ms
54,664 KB
testcase_20 AC 64 ms
52,652 KB
testcase_21 AC 98 ms
55,464 KB
testcase_22 AC 67 ms
54,172 KB
testcase_23 AC 71 ms
54,064 KB
testcase_24 AC 56 ms
53,348 KB
testcase_25 AC 96 ms
55,600 KB
testcase_26 AC 65 ms
53,908 KB
testcase_27 AC 56 ms
53,336 KB
testcase_28 AC 100 ms
55,492 KB
testcase_29 AC 93 ms
54,980 KB
testcase_30 AC 105 ms
55,992 KB
testcase_31 AC 91 ms
55,104 KB
testcase_32 AC 67 ms
52,996 KB
testcase_33 AC 55 ms
53,348 KB
testcase_34 AC 55 ms
52,408 KB
testcase_35 AC 54 ms
51,292 KB
testcase_36 AC 101 ms
55,188 KB
testcase_37 AC 54 ms
53,340 KB
testcase_38 AC 54 ms
52,380 KB
testcase_39 AC 54 ms
53,352 KB
testcase_40 AC 55 ms
53,344 KB
testcase_41 AC 56 ms
52,388 KB
testcase_42 AC 55 ms
53,288 KB
testcase_43 AC 54 ms
52,368 KB
testcase_44 AC 53 ms
53,340 KB
testcase_45 AC 53 ms
53,348 KB
testcase_46 AC 55 ms
53,340 KB
testcase_47 AC 54 ms
53,348 KB
testcase_48 AC 54 ms
53,288 KB
testcase_49 AC 56 ms
53,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long x = sc.nextLong();
        long a = sc.nextLong();
        long y = sc.nextLong();
        long b = sc.nextLong();
        HashMap<Long, Integer> countsX = getCount(x);
        HashMap<Long, Integer> countsY = getCount(y);
        for (long z : countsY.keySet()) {
            if (!countsX.containsKey(z) || countsX.get(z) * a < countsY.get(z) * b) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
    
    static HashMap<Long, Integer> getCount(long x) {
        HashMap<Long, Integer> ans = new HashMap<>();
        for (long i = 2; i <= Math.sqrt(x); i++) {
            while (x % i == 0) {
                ans.put(i, ans.getOrDefault(i, 0) + 1);
                x /= i;
            }
        }
        if (x > 1) {
            ans.put(x, ans.getOrDefault(x, 0) + 1);
        }
        return ans;
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0