結果

問題 No.1973 Divisor Sequence
ユーザー KudeKude
提出日時 2022-06-10 21:44:45
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,022 bytes
コンパイル時間 2,656 ms
コンパイル使用メモリ 234,384 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 06:18:54
合計ジャッジ時間 12,372 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 372 ms
4,348 KB
testcase_03 AC 11 ms
4,348 KB
testcase_04 AC 222 ms
4,348 KB
testcase_05 AC 24 ms
4,348 KB
testcase_06 AC 121 ms
4,348 KB
testcase_07 AC 31 ms
4,348 KB
testcase_08 AC 71 ms
4,348 KB
testcase_09 AC 194 ms
4,348 KB
testcase_10 AC 360 ms
4,348 KB
testcase_11 AC 36 ms
4,348 KB
testcase_12 AC 104 ms
4,348 KB
testcase_13 AC 44 ms
4,348 KB
testcase_14 AC 1,760 ms
4,348 KB
testcase_15 AC 639 ms
4,348 KB
testcase_16 AC 318 ms
4,348 KB
testcase_17 AC 303 ms
4,348 KB
testcase_18 AC 52 ms
4,348 KB
testcase_19 AC 401 ms
4,348 KB
testcase_20 AC 52 ms
4,348 KB
testcase_21 AC 153 ms
4,348 KB
testcase_22 AC 262 ms
4,348 KB
testcase_23 AC 261 ms
4,348 KB
testcase_24 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic pop
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using mint = modint1000000007;

std::vector<long long> divisors(long long x) {
    std::vector<long long> res1, res2;
    long long d = 1;
    for(; d * d < x; d++) {
        if (x % d == 0) {
            res1.push_back(d);
            res2.push_back(x / d);
        }
    }
    if (d * d == x) res1.push_back(d);
    int sz = res2.size();
    res1.reserve(res1.size() + sz);
    for(int i = sz - 1; i >= 0; i--) res1.push_back(res2[i]);
    return res1;
}

std::vector<std::pair<long long, int>> factorize(long long x) {
    std::vector<std::pair<long long, int>> ret;
    for(long long p = 2; p * p <= x; p++) {
        int cnt = 0;
        while(x % p == 0) x /= p, cnt++;
        if (cnt) ret.emplace_back(p, cnt);
    }
    if (x > 1) ret.emplace_back(x, 1);
    return ret;
}

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll m;
  cin >> n >> m;
  auto divs = divisors(m);
  auto fs = factorize(m);
  int sz = divs.size();
  vector<mint> dp(sz, 1);
  rep(_, n - 1) {
    for(auto [p, _]: fs) {
      int j = sz - 1;
      rrep(i, sz) if (divs[i] % p == 0) {
        ll x = divs[i] / p;
        while(divs[j] > x) j--;
        dp[j] += dp[i];
      }
    }
    reverse(all(dp));
  }
  mint ans = accumulate(all(dp), mint());
  cout << ans.val() << '\n';
}
0