結果

問題 No.2318 Phys Bone Maker
ユーザー risujiroh
提出日時 2023-05-26 21:37:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 600 ms / 3,000 ms
コード長 2,768 bytes
コンパイル時間 3,594 ms
コンパイル使用メモリ 264,824 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 05:37:24
合計ジャッジ時間 9,046 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#if __INCLUDE_LEVEL__ == 0

#include <bits/stdc++.h>

using namespace std;

#undef assert
#define assert(expr) (expr) || (__builtin_unreachable(), 0)

#include __BASE_FILE__

namespace std::ranges::views {

namespace {

using Fp = atcoder::modint998244353;

void solve() {
  int64_t n;
  cin >> n;
  vector<int64_t> ds;
  for (int64_t i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ds.push_back(i);
      if (i * i < n) {
        ds.push_back(n / i);
      }
    }
  }
  sort(ds);
  vector<Fp> f(ssize(ds));
  f[0] = 1;
  vector<int> c(ssize(f), 1);
  for (int i : iota(1, ssize(f))) {
    for (int j : iota(0, i)) {
      if (ds[i] % ds[j]) {
        continue;
      }
      auto q = ds[i] / ds[j];
      auto t = ds[j];
      while (true) {
        auto g = gcd(t, q);
        if (g == 1) {
          break;
        }
        t /= g;
      }
      f[i] += f[j] * c[lower_bound(ds, t) - begin(ds)];
      ++c[i];
    }
  }
  cout << f.back() << '\n';
}

}  // namespace

}  // namespace std::ranges::views

using views::solve;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}

#else  // __INCLUDE_LEVEL__

#include <atcoder/modint>

namespace std {

template <class T1, class T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
  return is >> p.first >> p.second;
}

template <class... Ts>
istream& operator>>(istream& is, tuple<Ts...>& t) {
  return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t);
}

template <class... Ts>
istream& operator>>(istream& is, tuple<Ts&...>&& t) {
  return is >> t;
}

template <class R, enable_if_t<!is_convertible_v<R, string>>* = nullptr>
auto operator>>(istream& is, R&& r) -> decltype(is >> *begin(r)) {
  for (auto&& e : r) {
    is >> e;
  }
  return is;
}

template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << p.first << ' ' << p.second;
}

template <class... Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
  auto f = [&os](const auto&... xs) -> ostream& {
    [[maybe_unused]] auto sep = "";
    ((os << exchange(sep, " ") << xs), ...);
    return os;
  };
  return apply(f, t);
}

template <class R, enable_if_t<!is_convertible_v<R, string_view>>* = nullptr>
auto operator<<(ostream& os, R&& r) -> decltype(os << *begin(r)) {
  auto sep = "";
  for (auto&& e : r) {
    os << exchange(sep, " ") << e;
  }
  return os;
}

}  // namespace std

namespace atcoder {

template <class T, internal::is_modint_t<T>* = nullptr>
istream& operator>>(istream& is, T& x) {
  int v;
  is >> v;
  x = T::raw(v);
  return is;
}

template <class T, internal::is_modint_t<T>* = nullptr>
ostream& operator<<(ostream& os, const T& x) {
  return os << x.val();
}

}  // namespace atcoder

#endif  // __INCLUDE_LEVEL__
0