結果

問題 No.1581 Multiple Sequence
ユーザー srjywrdnprkt
提出日時 2023-04-18 23:49:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 105,220 KB
最終ジャッジ日時 2025-02-12 10:04:24
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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;

vector<ll> ans(1e5+1, -1);
const ll modc = 1e9+7;

ll f(ll X){
    if (X == 1) return 1;
    if (ans[X] != -1) return ans[X];
    ll res=1;
    for (ll i = 1; i*i <= X; i++){
        if (X % i == 0){
            res += f(X/i-1);
            if (i != 1 && i*i != X) res += f(i-1);
            res %= modc;
        }
    }
    return ans[X] = res;
}

int main(){

    ll M;
    cin >> M;
    cout << f(M) << endl;

    return 0;
}
0