結果

問題 No.847 Divisors of Power
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-24 21:53:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,094 bytes
コンパイル時間 2,660 ms
コンパイル使用メモリ 80,216 KB
実行使用メモリ 61,864 KB
最終ジャッジ日時 2024-04-22 14:04:42
合計ジャッジ時間 8,661 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 127 ms
41,076 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
      }
    }
  }
}
0