結果
| 問題 |
No.1396 Giri
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-02-14 21:26:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 510 ms / 2,000 ms |
| コード長 | 840 bytes |
| コンパイル時間 | 2,337 ms |
| コンパイル使用メモリ | 202,616 KB |
| 最終ジャッジ日時 | 2025-01-18 20:36:18 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001
int main(){
int N;
cin>>N;
vector<int> P(N+1,-1);
for(int i=2;i<=N;i++){
if(P[i]!=-1)continue;
for(int j=i;j<=N;j+=i){
P[j] = i;
}
}
bool f = true;
map<int,int> mp;
for(int i=N;i>=2;i--){
if(P[i]==i){
if(f){
f=false;
continue;
}
}
map<int,int> p;
int x = i;
while(x!=1){
p[P[x]]++;
x /= P[x];
}
for(auto a:p){
mp[a.first] = max(mp[a.first],a.second);
}
}
mint ans= 1;
for(auto a:mp){
ans *= mint(a.first).pow(a.second);
}
cout<<ans.val()<<endl;
return 0;
}
沙耶花