結果
問題 | No.2318 Phys Bone Maker |
ユーザー | milanis48663220 |
提出日時 | 2023-05-26 21:46:10 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 353 ms / 3,000 ms |
コード長 | 2,964 bytes |
コンパイル時間 | 1,539 ms |
コンパイル使用メモリ | 137,000 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 06:04:49 |
合計ジャッジ時間 | 5,762 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #include <atcoder/modint> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template<typename T> vector<vector<T>> vec2d(int n, int m, T v){ return vector<vector<T>>(n, vector<T>(m, v)); } template<typename T> vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){ return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v))); } template<typename T> void print_vector(vector<T> v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using mint = atcoder::modint998244353; ostream& operator<<(ostream& os, const mint& m){ os << m.val(); return os; } using P = pair<ll, int>; map<ll, int> factorize(ll n){ ll m = n; map<ll, int> ans; for(ll p = 2; p*p <= n; p++){ if(m%p != 0) continue; int cnt = 0; while(m%p == 0){ cnt++; m /= p; } ans[p] = cnt; } if(m != 1) ans[m] = 1; return ans; } vector<ll> divs(ll n){ vector<ll> ans; for(ll x = 1; x*x <= n; x++){ if(n%x != 0) continue; ans.push_back(x); if(x*x != n) ans.push_back(n/x); } sort(ans.begin(), ans.end()); return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; ll n; cin >> n; auto v = divs(n); auto mp = factorize(n); vector<ll> p; for(auto [x, y]: mp) p.push_back(x); int m = v.size(); auto c = vec2d(m, p.size(), 0); for(int i = 0; i < m; i++){ ll cur = v[i]; for(int j = 0; j < p.size(); j++){ while(cur%p[j] == 0){ cur /= p[j]; c[i][j]++; } } } vector<mint> dp(m); dp[0] = 1; for(int i = 0; i < m; i++){ for(int j = 0; j < i; j++){ if(v[i]%v[j] != 0){ continue; } mint x = 1; for(int k = 0; k < p.size(); k++){ if(c[i][k] == c[j][k]){ x *= c[i][k]+1; } // cout << c[i][k] << ' ' << c[j][k] << endl; } dp[i] += dp[j]*x; // cout << v[j] << "->" << v[i] << ' ' << x << endl; } } cout << dp.back() << endl; }