結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;

    vector<bool> prime(n + 1, true);
    for (int i = 2; i * i <= n; i++) {
        if (not prime.at(i)) continue;
        for (int j = i; i * j <= n; j++) {
            prime.at(i * j) = false;
        }
    }
    
    vector<int> primes;
    for (int i = 2; i <= n; i++) {
        if (not prime.at(i)) continue;
        int m = n;
        while (m >= i) {
            primes.push_back(i);
            m /= i;
        }
    }
    primes.pop_back();
    
    const int64_t mod = 998244353;
    int64_t ans = 1;
    for (int x : primes) {
        ans *= x;
        ans %= mod;
    }

    cout << ans << endl;
}
0