結果

問題 No.1396 Giri
ユーザー t33f
提出日時 2021-02-14 21:32:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 727 ms
コンパイル使用メモリ 72,400 KB
最終ジャッジ日時 2025-01-18 20:43:27
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
using namespace std;
constexpr int M = 998244353;

bool is_prime(int x) {
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0) return false;
    return true;
}

int main() {
    int n; cin >> n;
    vector<int> ps;
    bool b[n+1];
    fill(b, b+n+1, true);
    for (int i = 2; i <= n; i++)
        if (b[i]) {
            for (int j = i; j <= n; j += i) b[j] = false;
            ps.push_back(i);
        }
    ps.pop_back();
    vector<int> qs;
    long long ans = 1;
    for (int p : ps) {
        long long q = p;
        while (q * p <= n) q *= p;
        ans = ans * q % M;
    }
    cout << ans << endl;
}
0