結果
問題 |
No.847 Divisors of Power
|
ユーザー |
![]() |
提出日時 | 2019-08-24 21:53:03 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,094 bytes |
コンパイル時間 | 2,305 ms |
コンパイル使用メモリ | 80,080 KB |
実行使用メモリ | 60,876 KB |
最終ジャッジ日時 | 2024-10-14 13:18:42 |
合計ジャッジ時間 | 8,218 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 1 WA * 14 TLE * 1 -- * 10 |
ソースコード
import java.util.*; public class Main { static HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); static ArrayList<Integer> list = new ArrayList<Integer>(); static int ans = 0; static int k = 0; static long M = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); k = sc.nextInt(); M = sc.nextLong(); func(n); Collections.sort(list); dfs(-1, 1); System.out.println(ans); } public static void func(int n) { int a = 1; for(int i = 2; i * i <= n; i++) { if((n % i) == 0) { if(list.contains(i)) { map.put(i, map.get(i) + 1); } else { list.add(i); map.put(i, 1); } a = i; break; } } if(a > 1) func(n / a); } public static void dfs(int n, long m) { if(n == list.size() - 1) { ans++; } else { for(int i = 0; i <= map.get(list.get(n + 1)) * k; i++) { long t = (long)Math.pow(list.get(n + 1), i); if(m * t <= M) dfs(n + 1, m * t); } } } }