結果

問題 No.847 Divisors of Power
ユーザー tentententen
提出日時 2020-08-31 19:13:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 278 ms / 2,000 ms
コード長 1,256 bytes
コンパイル時間 3,167 ms
コンパイル使用メモリ 75,912 KB
実行使用メモリ 67,424 KB
最終ジャッジ日時 2023-08-10 15:35:40
合計ジャッジ時間 8,180 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,452 KB
testcase_01 AC 123 ms
55,908 KB
testcase_02 AC 121 ms
55,716 KB
testcase_03 AC 118 ms
56,044 KB
testcase_04 AC 125 ms
55,968 KB
testcase_05 AC 121 ms
56,488 KB
testcase_06 AC 123 ms
56,028 KB
testcase_07 AC 126 ms
55,912 KB
testcase_08 AC 128 ms
55,460 KB
testcase_09 AC 130 ms
55,452 KB
testcase_10 AC 121 ms
55,936 KB
testcase_11 AC 127 ms
55,560 KB
testcase_12 AC 122 ms
56,124 KB
testcase_13 AC 126 ms
55,980 KB
testcase_14 AC 123 ms
55,808 KB
testcase_15 AC 254 ms
62,332 KB
testcase_16 AC 118 ms
56,128 KB
testcase_17 AC 122 ms
56,120 KB
testcase_18 AC 131 ms
56,244 KB
testcase_19 AC 155 ms
56,008 KB
testcase_20 AC 120 ms
55,800 KB
testcase_21 AC 187 ms
58,848 KB
testcase_22 AC 120 ms
56,012 KB
testcase_23 AC 121 ms
55,864 KB
testcase_24 AC 278 ms
67,424 KB
testcase_25 AC 122 ms
56,264 KB
testcase_26 AC 119 ms
56,056 KB
testcase_27 AC 121 ms
53,980 KB
testcase_28 AC 119 ms
56,192 KB
testcase_29 AC 118 ms
56,032 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