結果

問題 No.1529 Constant Lcm
ユーザー Nzt3
提出日時 2021-06-04 23:45:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 413 ms / 3,000 ms
コード長 669 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 175,340 KB
実行使用メモリ 10,320 KB
最終ジャッジ日時 2024-11-20 09:20:33
合計ジャッジ時間 6,875 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int main(){
  int N;
  cin>>N;
  vector<int>prime(N+1);
  for(int i=2;i<=N;i++){
    if(prime[i]!=0)continue;
    for(int j=i;j<=N;j+=i){
      prime[j]=i;
    }
  }
  unordered_map<int,int>ans;
  for(int i=1;i<=N/2;i++){
    unordered_map<int,int>now;
    int t=i;
    while(t!=1){
      now[prime[t]]++;
      t/=prime[t];
    }
    t=N-i;
    while(t!=1){
      now[prime[t]]++;
      t/=prime[t];
    }
    for(auto i:now)ans[i.first]=max(ans[i.first],i.second);
  }
  long long ret=1;
  for(auto i:ans){
    for(int j=i.second;j>0;j--){
      ret=i.first*ret%mod;
    }
  }
  cout<<ret<<'\n';
}
0