結果

問題 No.1529 Constant Lcm
ユーザー AuroraAurora
提出日時 2021-06-06 19:09:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 759 bytes
コンパイル時間 1,939 ms
コンパイル使用メモリ 178,280 KB
実行使用メモリ 69,912 KB
最終ジャッジ日時 2023-08-15 02:14:07
合計ジャッジ時間 7,146 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
11,432 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  long long int ans = 1,MOD=998244353;
  int N;
  cin >> N;
  vector<map<int,int>> cnt(N-1);
  vector<int> p(0);
  for(int i=2;i<N;i++){
    int t = i;
    for(int j=0;j<p.size();j++){
      while(t%p[j] == 0){
        t /= p[j];
        cnt[i-1][p[j]]++;
      }
    }
    if(t != 1) cnt[i-1][t]++;
    if(t == i) p.push_back(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]);
  }
  for(auto x:Map){
    for(int j=0;j<x.second;j++){
      ans *= x.first;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}
0