Advertisement
pb_jiang

ABC300E

Aug 22nd, 2023
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <assert.h>
  2. #include <bits/stdc++.h>
  3. #include <atcoder/modint>
  4. using namespace std;
  5.  
  6. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  7.  
  8. using ll = long long;
  9. using pii = pair<int, int>;
  10. using pll = pair<ll, ll>;
  11. using vl = vector<ll>;
  12. using vi = vector<int>;
  13. using mint = atcoder::modint998244353;
  14.  
  15. map<ll, mint> ss;
  16. void gets(ll target)
  17. {
  18.     if (ss.count(target))
  19.         return;
  20.     if (target == 1)
  21.         return;
  22.     ss[target] = 0;
  23.     for (int i = 2; i <= 6; ++i)
  24.         if (target % i == 0)
  25.             gets(target / i);
  26. }
  27.  
  28. int main(int argc, char **argv)
  29. {
  30.     ll n;
  31.     cin >> n;
  32.     ll nn = n;
  33.     while (nn % 2 == 0)
  34.         nn = nn / 2;
  35.     while (nn % 3 == 0)
  36.         nn = nn / 3;
  37.     while (nn % 5 == 0)
  38.         nn = nn / 5;
  39.     if (nn != 1) {
  40.         cout << 0 << endl;
  41.         return 0;
  42.     }
  43.     gets(n);
  44.     ss[1] = 1;
  45.     for (auto p : ss)
  46.         for (int i = 2; i <= 6; ++i) {
  47.             ll ns = p.first * i;
  48.             mint prob = p.second;
  49.             if (ss.count(ns))
  50.                 ss[ns] += prob / 5;
  51.         }
  52.     cout << ss[n].val() << endl;
  53.     return 0;
  54. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement