結果
問題 |
No.2903 A Round-the-World Trip with the Tent
|
ユーザー |
![]() |
提出日時 | 2024-10-02 14:28:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 705 bytes |
コンパイル時間 | 2,516 ms |
コンパイル使用メモリ | 201,760 KB |
最終ジャッジ日時 | 2025-02-24 14:28:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } #include <atcoder/modint> using mint = atcoder::modint998244353; int main() { fast_io(); long long k; int n; cin >> k >> n; vector<int> facts; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { facts.push_back(i); if (i * i != n) { facts.push_back(n / i); } } } sort(facts.begin(), facts.end()); int M = facts.size(); vector<mint> dp(M); for (int i = 0; i < M; i++) { dp[i] = mint(2).pow(facts[i]) + (k > 1 ? 1 : 0); for (int j = 0; j < i; j++) { if (facts[i] % facts[j] == 0) { dp[i] -= dp[j]; } } } cout << dp[M - 1].val() << endl; }