結果

問題 No.847 Divisors of Power
ユーザー tentententen
提出日時 2020-08-31 19:13:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 294 ms / 2,000 ms
コード長 1,256 bytes
コンパイル時間 2,812 ms
コンパイル使用メモリ 80,300 KB
実行使用メモリ 64,888 KB
最終ジャッジ日時 2024-04-28 08:34:01
合計ジャッジ時間 6,795 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
53,768 KB
testcase_01 AC 111 ms
53,600 KB
testcase_02 AC 117 ms
53,808 KB
testcase_03 AC 121 ms
53,880 KB
testcase_04 AC 120 ms
54,140 KB
testcase_05 AC 116 ms
53,828 KB
testcase_06 AC 119 ms
53,904 KB
testcase_07 AC 118 ms
54,004 KB
testcase_08 AC 98 ms
52,680 KB
testcase_09 AC 114 ms
54,052 KB
testcase_10 AC 126 ms
54,084 KB
testcase_11 AC 118 ms
54,228 KB
testcase_12 AC 121 ms
53,768 KB
testcase_13 AC 122 ms
54,060 KB
testcase_14 AC 123 ms
53,748 KB
testcase_15 AC 231 ms
60,880 KB
testcase_16 AC 117 ms
53,964 KB
testcase_17 AC 120 ms
53,864 KB
testcase_18 AC 116 ms
52,984 KB
testcase_19 AC 116 ms
53,852 KB
testcase_20 AC 124 ms
54,008 KB
testcase_21 AC 171 ms
56,632 KB
testcase_22 AC 115 ms
54,168 KB
testcase_23 AC 116 ms
53,716 KB
testcase_24 AC 294 ms
64,888 KB
testcase_25 AC 106 ms
52,856 KB
testcase_26 AC 103 ms
53,096 KB
testcase_27 AC 103 ms
52,552 KB
testcase_28 AC 115 ms
53,760 KB
testcase_29 AC 103 ms
52,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int k = sc.nextInt();
    	int m = sc.nextInt();
    	TreeMap<Integer, Integer> primes = new TreeMap<>();
    	for (int i = 2; i <= Math.sqrt(n); i++) {
    	    while (n % i == 0) {
    	        if (primes.containsKey(i)) {
    	            primes.put(i, primes.get(i) + 1);
    	        } else {
    	            primes.put(i, 1);
    	        }
    	        n /= i;
    	    }
    	}
    	if (n > 1) {
    	    if (primes.containsKey(n)) {
    	        primes.put(n, primes.get(n) + 1);
    	    } else {
    	        primes.put(n, 1);
    	    }
    	}
    	TreeSet<Integer> results = new TreeSet<>();
    	results.add(1);
    	for (int x : primes.keySet()) {
    	    Integer tmp = Integer.MAX_VALUE;
    	    while ((tmp = results.lower(tmp)) != null) {
    	        long base = tmp.intValue();
    	        for (long i = 1; i <= (long)k * primes.get(x); i++) {
    	            base *= x;
    	            if (base > m) {
    	                break;
    	            }
    	            results.add((int)base);
    	        }
    	    }
    	}
    	System.out.println(results.size());
    }
}
0