結果

問題 No.1396 Giri
ユーザー KKT89KKT89
提出日時 2021-02-22 18:29:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,068 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 202,924 KB
実行使用メモリ 4,528 KB
最終ジャッジ日時 2023-10-21 13:29:30
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,476 KB
testcase_01 AC 7 ms
4,476 KB
testcase_02 AC 10 ms
4,528 KB
testcase_03 AC 7 ms
4,476 KB
testcase_04 AC 7 ms
4,476 KB
testcase_05 AC 10 ms
4,528 KB
testcase_06 AC 7 ms
4,476 KB
testcase_07 AC 7 ms
4,528 KB
testcase_08 AC 8 ms
4,528 KB
testcase_09 AC 7 ms
4,528 KB
testcase_10 AC 7 ms
4,528 KB
testcase_11 AC 7 ms
4,528 KB
testcase_12 AC 7 ms
4,528 KB
testcase_13 AC 7 ms
4,528 KB
testcase_14 AC 7 ms
4,528 KB
testcase_15 AC 7 ms
4,528 KB
testcase_16 AC 7 ms
4,528 KB
testcase_17 AC 7 ms
4,528 KB
testcase_18 AC 7 ms
4,528 KB
testcase_19 AC 9 ms
4,528 KB
testcase_20 AC 9 ms
4,528 KB
testcase_21 AC 10 ms
4,528 KB
testcase_22 AC 9 ms
4,528 KB
testcase_23 AC 10 ms
4,528 KB
testcase_24 AC 9 ms
4,528 KB
testcase_25 AC 10 ms
4,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

constexpr ll mod=998244353;

ll mod_pow(ll x,ll n,ll Mod){
    x%=Mod;
    ll res=1;
    while(n>0){
        if(n&1LL)res=res*x%Mod;
        x=x*x%Mod; n>>=1LL;
    }
    return res;
}

const int N=1000001;
bool is_not_prime[N];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    is_not_prime[0]=is_not_prime[1]=true;
    for(int i=2;i<N;i++){
        if(!is_not_prime[i]){
            for(int j=i+i;j<N;j+=i)is_not_prime[j]=true;
        }
    }
    int n; cin >> n;
    ll res=1; bool f=true;
    for(ll i=n;i>=1;i--){
        if(f and !is_not_prime[i]){
            f=false;
        }
        else if(!is_not_prime[i]){
            int cnt=0;
            ll p=1;
            while(p*i<=n){
                cnt++; p*=i;
            }
            res=res*mod_pow(i,cnt,mod)%mod;
        }
    }
    cout << res << endl;
}
0