結果

問題 No.847 Divisors of Power
ユーザー htensai
提出日時 2019-11-11 14:34:08
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,157 bytes
コンパイル時間 2,222 ms
コンパイル使用メモリ 79,420 KB
実行使用メモリ 42,128 KB
最終ジャッジ日時 2024-09-15 05:14:09
合計ジャッジ時間 7,752 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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++) {
	        value *= x;
	        if (value > m) {
	            break;
	        }
	        count++;
	        calc(idx + 1, value);
	    }
	}
}
0