結果

問題 No.1396 Giri
ユーザー Nzt3Nzt3
提出日時 2021-02-14 22:02:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 719 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 174,360 KB
実行使用メモリ 10,636 KB
最終ジャッジ日時 2023-09-29 15:31:38
合計ジャッジ時間 6,108 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 465 ms
10,636 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 455 ms
10,588 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 30 ms
4,376 KB
testcase_19 AC 222 ms
7,080 KB
testcase_20 AC 330 ms
8,524 KB
testcase_21 AC 403 ms
9,820 KB
testcase_22 AC 456 ms
10,608 KB
testcase_23 AC 445 ms
10,612 KB
testcase_24 AC 471 ms
10,608 KB
testcase_25 AC 448 ms
10,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h> 
using namespace std;
const int64_t mod=998244353;
int main(){
  int n;
  cin>>n;
  vector<int>sieve(n+1);
  iota(sieve.begin(),sieve.end(),0);
  for(int64_t i=2;i<=n;i++){
    if(sieve[i]!=i)continue;
    for(int64_t j=i*i;j<=n;j+=i){
      sieve[j]=i;
    }
  }
  int skip=n;
  while(sieve[skip]!=skip)skip--;
  map<int,int>divr;
  for(int i=2;i<=n;i++){
    if(i==skip)continue;
    int t=i;
    map<int,int>cnt;
    while(sieve[t]!=1){
      cnt[sieve[t]]++;
      t/=sieve[t];
    }
    for(auto j:cnt){
      divr[j.first]=max(divr[j.first],j.second);
    }
  }
  int64_t ans=1;
  for(auto i:divr){
    for(int j=0;j<i.second;j++){
      ans=ans*i.first%mod;
    }
  }
  cout<<ans<<'\n';
}
0