結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2019-11-11 14:35:32 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,161 bytes |
| コンパイル時間 | 2,972 ms |
| コンパイル使用メモリ | 79,504 KB |
| 実行使用メモリ | 41,852 KB |
| 最終ジャッジ日時 | 2024-09-15 05:14:37 |
| 合計ジャッジ時間 | 7,411 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 WA * 1 |
ソースコード
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);
}
}
}
htensai