結果
| 問題 |
No.1973 Divisor Sequence
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2022-06-10 21:44:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,022 bytes |
| コンパイル時間 | 2,355 ms |
| コンパイル使用メモリ | 223,600 KB |
| 最終ジャッジ日時 | 2025-01-29 19:42:07 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 TLE * 1 |
ソースコード
#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';
}
Kude