結果

問題 No.2318 Phys Bone Maker
ユーザー pointN
提出日時 2023-05-26 22:07:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 584 ms / 3,000 ms
コード長 2,167 bytes
コンパイル時間 1,566 ms
コンパイル使用メモリ 142,556 KB
最終ジャッジ日時 2025-02-13 06:44:34
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

const ll mod = 998244353;

ll dfs(int now,vector<ll>& dp,const vector<vector<int>>& R, const vector<vector<ll>>& CO){
  if(dp[now]!=-1) return dp[now];
  ll res = 0;
  rep(i,sz(R[now])){
    res += dfs(R[now][i],dp,R,CO) * CO[now][i] % mod;
  }
  res %= mod;
  dp[now] = res;
  return res;
}

int main(){
  ll X; cin >> X;
  vector<ll> A;
  for(ll i=1;i*i<=X;i++){
    if(X%i==0){
      A.pb(i);
      if(i*i!=X) A.pb(X/i);
    }
  }
  sort(all(A));
  map<ll,int> P;
  ll tmp = X;
  for(ll i=2;i*i<=tmp; i++){
    while(tmp%i==0){
      P[i]++; tmp/=i;
    }
    if(tmp==1) break;
  }
  if(tmp!=1) P[tmp]++;
  int N = sz(A);
  
  
  vector<vector<ll>> V(N);
  rep(i,N){
    ll now = A[i];
    for(auto p:P){
      ll c = 0;
      while(now%p.first==0){
        c++;
        now/=p.first;
      }
      V[i].pb(c);
    }
  }
  vector<vector<int>> R(N);
  vector<vector<ll>> CO(N);
  ll cnt = 0;
  rep(i,N){
    rep(j,i){
      ll now = 1;
      rep(k,sz(P)){
        if(V[i][k]>V[j][k]){
          now *= 1;
        }
        else if(V[i][k]==V[j][k]){
          now *= (V[j][k]+1);
          now %= mod;
        }
        else{
          now = 0;
          break;
        }
      }
      if(now){
        R[i].pb(j);
        CO[i].pb(now);
        cnt++;
      }
    }
  }
  vector<ll> dp(N,-1);
  dp[0]=1;
  cout << dfs(N-1,dp,R,CO) << endl;
  return 0;
}
0