結果
| 問題 | 
                            No.1529 Constant Lcm
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-06-06 17:44:54 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 699 bytes | 
| コンパイル時間 | 1,692 ms | 
| コンパイル使用メモリ | 177,664 KB | 
| 実行使用メモリ | 351,104 KB | 
| 最終ジャッジ日時 | 2024-11-23 01:20:42 | 
| 合計ジャッジ時間 | 46,440 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 16 TLE * 8 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<map<int,int>> cnt(N-1);
  for(int i=1;i<N;i++){
    int t = i;
    for(int j=2;j<=sqrt(i);j++){
      while(t%j == 0){
        t /= j;
        cnt[i-1][j]++;
      }
    }
    if(t != 1) cnt[i-1][t]++;
  }
  map<int,int> Map;
  for(int i=0;i<N-1;i++){
    for(auto x:cnt[i]) Map[x.first] = max(Map[x.first],cnt[i][x.first]+cnt[N-2-i][x.first]);
    for(auto x:cnt[N-2-i]) Map[x.first] = max(Map[x.first],cnt[i][x.first]+cnt[N-2-i][x.first]);
  }
  long long int ans = 1,MOD=998244353;
  for(auto x:Map){
    for(int j=0;j<x.second;j++){
      ans *= x.first;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}