結果
問題 | No.1529 Constant Lcm |
ユーザー | Aurora |
提出日時 | 2021-06-06 19:11:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 791 bytes |
コンパイル時間 | 2,050 ms |
コンパイル使用メモリ | 178,816 KB |
実行使用メモリ | 314,192 KB |
最終ジャッジ日時 | 2023-08-15 02:16:30 |
合計ジャッジ時間 | 25,166 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,384 KB |
testcase_01 | AC | 5 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2,725 ms
270,264 KB |
testcase_11 | AC | 910 ms
107,436 KB |
testcase_12 | AC | 34 ms
8,616 KB |
testcase_13 | AC | 2,238 ms
233,040 KB |
testcase_14 | AC | 1,248 ms
134,040 KB |
testcase_15 | AC | 1,458 ms
158,360 KB |
testcase_16 | AC | 1,118 ms
132,728 KB |
testcase_17 | AC | 545 ms
67,888 KB |
testcase_18 | AC | 601 ms
73,432 KB |
testcase_19 | AC | 1,349 ms
145,608 KB |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | AC | 2,902 ms
288,800 KB |
ソースコード
#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-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; }