結果

問題 No.847 Divisors of Power
ユーザー htensaihtensai
提出日時 2019-11-11 14:35:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,161 bytes
コンパイル時間 2,432 ms
コンパイル使用メモリ 75,824 KB
実行使用メモリ 57,984 KB
最終ジャッジ日時 2023-10-13 08:03:18
合計ジャッジ時間 7,766 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,000 KB
testcase_01 AC 123 ms
55,888 KB
testcase_02 AC 126 ms
56,532 KB
testcase_03 AC 125 ms
56,348 KB
testcase_04 AC 124 ms
55,852 KB
testcase_05 AC 124 ms
55,704 KB
testcase_06 AC 122 ms
56,192 KB
testcase_07 AC 122 ms
56,020 KB
testcase_08 AC 123 ms
55,832 KB
testcase_09 AC 127 ms
56,012 KB
testcase_10 AC 125 ms
55,872 KB
testcase_11 AC 122 ms
55,840 KB
testcase_12 AC 122 ms
56,124 KB
testcase_13 AC 125 ms
56,160 KB
testcase_14 AC 125 ms
55,988 KB
testcase_15 AC 168 ms
57,984 KB
testcase_16 AC 122 ms
55,920 KB
testcase_17 AC 126 ms
56,184 KB
testcase_18 AC 126 ms
56,152 KB
testcase_19 AC 125 ms
56,164 KB
testcase_20 AC 122 ms
56,008 KB
testcase_21 AC 153 ms
56,868 KB
testcase_22 AC 123 ms
56,032 KB
testcase_23 AC 124 ms
56,052 KB
testcase_24 AC 167 ms
57,312 KB
testcase_25 WA -
testcase_26 AC 124 ms
56,272 KB
testcase_27 AC 124 ms
55,896 KB
testcase_28 AC 120 ms
55,556 KB
testcase_29 AC 122 ms
55,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static HashMap<Integer, Integer> map = new HashMap<>();
    static int count = 0;
    static Integer[] arr;
    static int k;
    static int m;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		k = sc.nextInt();
		m = sc.nextInt();
		for (int i = 2; i <= Math.sqrt(n); i++) {
		    while (n % i == 0) {
		        if (map.containsKey(i)) {
		            map.put(i, map.get(i) + 1);
		        } else {
		            map.put(i, 1);
		        }
		        n /= i;
		    }
		}
		if (n != 1) {
	        if (map.containsKey(n)) {
	            map.put(n, map.get(n) + 1);
	        } else {
	            map.put(n, 1);
	        }
		}
		arr = map.keySet().toArray(new Integer[0]);
		calc(0, 1);
		System.out.println(count + 1);
	}
	
	static void calc(int idx, long value) {
	    if (idx >= arr.length) {
	        return;
	    }
	    int x = arr[idx];
	    calc(idx + 1, value);
	    for (int i = 0; i < map.get(x) * k; i++) {
	        if (value > m / x) {
	            break;
	        }
	        value *= x;
	        count++;
	        calc(idx + 1, value);
	    }
	}
}
0