結果
| 問題 |
No.1396 Giri
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-22 18:29:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 1,068 bytes |
| コンパイル時間 | 1,903 ms |
| コンパイル使用メモリ | 194,644 KB |
| 最終ジャッジ日時 | 2025-01-19 03:32:37 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#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;
}