結果

問題 No.2318 Phys Bone Maker
ユーザー pointNpointN
提出日時 2023-05-26 22:07:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 572 ms / 3,000 ms
コード長 2,167 bytes
コンパイル時間 2,510 ms
コンパイル使用メモリ 147,912 KB
実行使用メモリ 33,664 KB
最終ジャッジ日時 2023-08-26 11:44:17
合計ジャッジ時間 7,650 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 572 ms
33,664 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 11 ms
4,384 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 10 ms
4,376 KB
testcase_17 AC 10 ms
4,376 KB
testcase_18 AC 11 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 8 ms
4,380 KB
testcase_24 AC 10 ms
4,376 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 9 ms
4,376 KB
testcase_28 AC 6 ms
4,380 KB
testcase_29 AC 5 ms
4,376 KB
testcase_30 AC 7 ms
4,376 KB
testcase_31 AC 11 ms
4,376 KB
testcase_32 AC 14 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 8 ms
4,376 KB
testcase_35 AC 80 ms
5,952 KB
testcase_36 AC 300 ms
17,156 KB
testcase_37 AC 292 ms
18,680 KB
testcase_38 AC 273 ms
20,376 KB
testcase_39 AC 470 ms
23,356 KB
testcase_40 AC 450 ms
25,704 KB
testcase_41 AC 521 ms
26,284 KB
testcase_42 AC 493 ms
28,656 KB
testcase_43 AC 11 ms
4,376 KB
testcase_44 AC 47 ms
10,360 KB
testcase_45 AC 45 ms
9,652 KB
testcase_46 AC 462 ms
31,780 KB
testcase_47 AC 21 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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