結果

問題 No.1973 Divisor Sequence
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-14 07:55:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 2,529 bytes
コンパイル時間 1,193 ms
コンパイル使用メモリ 121,160 KB
実行使用メモリ 179,104 KB
最終ジャッジ日時 2023-08-20 00:01:39
合計ジャッジ時間 4,694 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 142 ms
29,780 KB
testcase_03 AC 9 ms
5,212 KB
testcase_04 AC 83 ms
18,676 KB
testcase_05 AC 22 ms
16,372 KB
testcase_06 AC 88 ms
25,312 KB
testcase_07 AC 20 ms
6,772 KB
testcase_08 AC 49 ms
14,696 KB
testcase_09 AC 71 ms
16,612 KB
testcase_10 AC 90 ms
20,248 KB
testcase_11 AC 15 ms
5,096 KB
testcase_12 AC 73 ms
20,548 KB
testcase_13 AC 22 ms
8,100 KB
testcase_14 AC 50 ms
17,552 KB
testcase_15 AC 124 ms
21,684 KB
testcase_16 AC 121 ms
25,852 KB
testcase_17 AC 76 ms
17,160 KB
testcase_18 AC 10 ms
4,448 KB
testcase_19 AC 100 ms
21,808 KB
testcase_20 AC 21 ms
5,964 KB
testcase_21 AC 111 ms
30,168 KB
testcase_22 AC 97 ms
22,104 KB
testcase_23 AC 240 ms
179,104 KB
testcase_24 AC 262 ms
46,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

const ll modc = 1e9+7;
class mint {
    ll x;
public:
    mint(ll x=0) : x((x%modc+modc)%modc) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= modc) x -= modc;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += modc-a.x) >= modc) x -= modc;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= modc;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(modc-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }

    friend istream& operator>>(istream& ip, mint&m) {
        ip >> m.x;
        return ip;
    }
};

map<long long, long long> prime;

void prime_factor(long long n){
    long long m = n;

    if (n % 2 == 0){
        while(n % 2 == 0){
            prime[2]++;
            n /= 2;
        }
    }

    for (long long i = 3; i*i <= m; i+=2){
        if (n % i == 0){
            while(n % i == 0){
                prime[i]++;
                n /= i;
            }
        }
    }

    if (n != 1){
        prime[n]++;
    }
}

int main(){

    ll N, M;
    cin >> N >> M;
    mint ans=1, S;
    prime_factor(M);
    for (auto [x, y] : prime){
        vector<vector<mint>> dp(N+1, vector<mint>(y+1));
        dp[0][0] = 1;
        for (int i=1; i<=N; i++){
            S = 0;
            for (int j=y; j>=0; j--){
                S += dp[i-1][y-j];
                dp[i][j] = S; 
            }
        }
        S = 0;
        for (int i=0; i<=y; i++) S += dp[N][i];
        ans *= S;
    }

    cout << ans << endl;
}
0