結果

問題 No.1973 Divisor Sequence
ユーザー SSRSSSRS
提出日時 2022-06-10 21:25:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 1,017 bytes
コンパイル時間 1,936 ms
コンパイル使用メモリ 175,880 KB
実行使用メモリ 179,064 KB
最終ジャッジ日時 2023-10-21 06:16:54
合計ジャッジ時間 4,773 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 162 ms
30,028 KB
testcase_03 AC 10 ms
5,504 KB
testcase_04 AC 96 ms
18,952 KB
testcase_05 AC 31 ms
16,644 KB
testcase_06 AC 100 ms
25,484 KB
testcase_07 AC 20 ms
7,012 KB
testcase_08 AC 54 ms
14,864 KB
testcase_09 AC 84 ms
16,908 KB
testcase_10 AC 104 ms
20,340 KB
testcase_11 AC 15 ms
5,456 KB
testcase_12 AC 81 ms
20,904 KB
testcase_13 AC 25 ms
8,400 KB
testcase_14 AC 53 ms
17,836 KB
testcase_15 AC 141 ms
21,976 KB
testcase_16 AC 138 ms
26,012 KB
testcase_17 AC 88 ms
17,436 KB
testcase_18 AC 6 ms
4,436 KB
testcase_19 AC 116 ms
22,032 KB
testcase_20 AC 21 ms
6,220 KB
testcase_21 AC 125 ms
30,500 KB
testcase_22 AC 115 ms
22,120 KB
testcase_23 AC 200 ms
179,064 KB
testcase_24 AC 274 ms
46,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int N;
  long long M;
  cin >> N >> M;
  vector<pair<long long, int>> F;
  for (long long i = 2; i * i <= M; i++){
    if (M % i == 0){
      int cnt = 0;
      while (M % i == 0){
        cnt++;
        M /= i;
      }
      F.push_back(make_pair(i, cnt));
    }
  }
  if (M > 1){
    F.push_back(make_pair(M, 1));
  }
  int cnt = F.size();
  long long ans = 1;
  for (int i = 0; i < cnt; i++){
    int e = F[i].second;
    vector<vector<long long>> dp(N, vector<long long>(e + 1, 0));
    for (int j = 0; j <= e; j++){
      dp[0][j] = 1;
    }
    for (int j = 0; j < N - 1; j++){
      long long S = 0;
      for (int k = e; k >= 0; k--){
        S += dp[j][e - k];
        if (S >= MOD){
          S -= MOD;
        }
        dp[j + 1][k] = S;
      }
    }
    long long m = 0;
    for (int j = 0; j <= e; j++){
      m += dp[N - 1][j];
      m %= MOD;
    }
    ans *= m;
    ans %= MOD;
  }
  cout << ans << endl;
}
0