結果

問題 No.1973 Divisor Sequence
ユーザー ぷらぷら
提出日時 2023-08-01 09:06:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 1,665 bytes
コンパイル時間 1,632 ms
コンパイル使用メモリ 139,276 KB
実行使用メモリ 89,492 KB
最終ジャッジ日時 2024-04-19 08:32:26
合計ジャッジ時間 3,304 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 84 ms
87,296 KB
testcase_03 AC 6 ms
10,496 KB
testcase_04 AC 45 ms
52,224 KB
testcase_05 AC 24 ms
45,696 KB
testcase_06 AC 52 ms
72,704 KB
testcase_07 AC 10 ms
14,848 KB
testcase_08 AC 26 ms
39,808 KB
testcase_09 AC 39 ms
45,952 KB
testcase_10 AC 50 ms
56,832 KB
testcase_11 AC 7 ms
10,240 KB
testcase_12 AC 43 ms
58,880 KB
testcase_13 AC 11 ms
19,200 KB
testcase_14 AC 24 ms
24,832 KB
testcase_15 AC 64 ms
61,952 KB
testcase_16 AC 67 ms
75,008 KB
testcase_17 AC 38 ms
47,616 KB
testcase_18 AC 3 ms
6,016 KB
testcase_19 AC 51 ms
62,080 KB
testcase_20 AC 8 ms
13,056 KB
testcase_21 AC 66 ms
88,832 KB
testcase_22 AC 52 ms
62,208 KB
testcase_23 AC 118 ms
89,492 KB
testcase_24 AC 156 ms
89,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

constexpr int mod = 1000000007;

int dp[500500][44];

void mpl(int &x,int y) {
    x += y;
    if(x >= mod) x -= mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    long long M;
    cin >> N >> M;
    vector<int>res;
    for(long long i = 2; i*i <= M; i++) {
        int cnt = 0;
        while(M%i == 0) {
            M /= i;
            cnt++;
        }
        if(cnt) res.push_back(cnt);
    }
    if(M > 1) res.push_back(1);
    int ans = 1;
    for(int i = 0; i < res.size(); i++) {
        for(int j = 0; j <= N; j++) {
            for(int k = 0; k <= res[i]; k++) {
                dp[j][k] = 0;
            }
        }
        dp[0][0] = 1;
        for(int j = 0; j < N; j++) {
            for(int k = 0; k <= res[i]; k++) {
                mpl(dp[j+1][res[i]-k],dp[j][k]);
            }
            for(int k = res[i]; k >= 1; k--) {
                mpl(dp[j+1][k-1],dp[j+1][k]);
            }
        }
        int sum = 0;
        for(int j = 0; j <= res[i]; j++) {
            mpl(sum,dp[N][j]);
        }
        ans = 1ll*ans*sum%mod;
    }
    cout << ans << "\n";
}
0