結果

問題 No.1529 Constant Lcm
ユーザー AuroraAurora
提出日時 2021-06-06 20:45:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,114 ms / 3,000 ms
コード長 791 bytes
コンパイル時間 1,943 ms
コンパイル使用メモリ 177,128 KB
実行使用メモリ 321,532 KB
最終ジャッジ日時 2023-08-15 10:19:12
合計ジャッジ時間 24,491 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1,826 ms
270,248 KB
testcase_11 AC 622 ms
107,244 KB
testcase_12 AC 24 ms
8,308 KB
testcase_13 AC 1,519 ms
232,832 KB
testcase_14 AC 852 ms
134,128 KB
testcase_15 AC 978 ms
158,440 KB
testcase_16 AC 748 ms
132,952 KB
testcase_17 AC 365 ms
67,836 KB
testcase_18 AC 401 ms
73,404 KB
testcase_19 AC 913 ms
145,404 KB
testcase_20 AC 2,111 ms
311,956 KB
testcase_21 AC 2,078 ms
314,100 KB
testcase_22 AC 2,064 ms
305,300 KB
testcase_23 AC 2,114 ms
321,532 KB
testcase_24 AC 2,062 ms
305,316 KB
testcase_25 AC 2,003 ms
288,664 KB
権限があれば一括ダウンロードができます

ソースコード

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++){
      if(p[j] > sqrt(i)) break;
      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/2;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