結果
| 問題 |
No.1396 Giri
|
| コンテスト | |
| ユーザー |
蜜蜂
|
| 提出日時 | 2021-02-14 21:30:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 1,059 bytes |
| コンパイル時間 | 1,651 ms |
| コンパイル使用メモリ | 168,524 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 08:49:35 |
| 合計ジャッジ時間 | 3,501 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lb = long double;
#define fi first
#define se second
#define pb push_back
constexpr ll mod = 998244353;
bool isprime(int num){
if(num<2) return false;
else if(num==2) return true;
else if(num%2==0) return false;
double sqrtNum=sqrt(num);
for(int i=3;i<=sqrtNum;i+=2){
if(num%i==0){
return false;
}
}
return true;
}
ll mpower(ll a,ll b,ll c){
ll z;
if(b==0){
z=1;
z%=c;
return z;
}
if(b==1){
z=a;
z%=c;
return z;
}
if(b%2==0){
z=mpower(a,b/2,c);
return (z*z)%c;
}
else{
z=mpower(a,b-1,c);
return (z*mpower(a,1,c))%c;
}
}
//aのb乗をcで割った余り
int main(){
ll n;
cin>>n;
ll ans=1;
for(int i=1;i<=n;i++){
if(isprime(i)==true){
ll x=i;
while(x*i<=n){
x*=i;
}
ans*=x;
ans%=mod;
}
}
for(int i=n;i>=1;i--){
if(isprime(i)==true){
ans*=mpower(i,mod-2,mod);
ans%=mod;
break;
}
}
cout<<ans<<endl;
}
蜜蜂