結果

問題 No.1581 Multiple Sequence
ユーザー merom686
提出日時 2021-07-02 22:19:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 1,118 bytes
コンパイル時間 1,820 ms
コンパイル使用メモリ 196,964 KB
最終ジャッジ日時 2025-01-22 16:14:59
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using mint = atcoder::modint1000000007;
using namespace std;
using ll = long long;

//int c = 0;
//vector<int> a;
//
//void dfs(int x, int s) {
//    if (s == 0) {
//        int n = a.size();
//        for (int i = 0; i < n; i++) {
//            cout << a[i] << " \n"[i == n - 1];
//        }
//        c++;
//        return;
//    }
//    int t = 0;
//    for (int i = 1;; i++) {
//        t += x;
//        s -= x;
//        if (s < 0) break;
//        if (s % t == 0) {
//            a.push_back(t);
//            dfs(t, s);
//            a.pop_back();
//        }
//    }
//}

int main() {
    //dfs(1, 12);
    //cout << c << endl;

    int m;
    cin >> m;

    vector<mint> dp(m + 1);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= m; i++) {
        mint t = 0;
        for (int j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                int k = i / j;
                t += dp[(i - j) / j];
                if (j != k) t += dp[(i - k) / k];
            }
        }
        dp[i] = t;
    }
    cout << dp[m].val() << endl;

    return 0;
}
0