結果
問題 | No.1529 Constant Lcm |
ユーザー | KKT89 |
提出日時 | 2021-06-04 20:54:45 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 608 ms / 3,000 ms |
コード長 | 1,357 bytes |
コンパイル時間 | 2,944 ms |
コンパイル使用メモリ | 220,988 KB |
実行使用メモリ | 15,208 KB |
最終ジャッジ日時 | 2023-08-12 10:24:18 |
合計ジャッジ時間 | 10,668 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
11,796 KB |
testcase_01 | AC | 19 ms
11,796 KB |
testcase_02 | AC | 18 ms
11,860 KB |
testcase_03 | AC | 19 ms
11,928 KB |
testcase_04 | AC | 18 ms
12,048 KB |
testcase_05 | AC | 20 ms
11,740 KB |
testcase_06 | AC | 21 ms
11,796 KB |
testcase_07 | AC | 21 ms
11,848 KB |
testcase_08 | AC | 20 ms
12,104 KB |
testcase_09 | AC | 20 ms
11,792 KB |
testcase_10 | AC | 524 ms
14,940 KB |
testcase_11 | AC | 201 ms
13,068 KB |
testcase_12 | AC | 28 ms
11,736 KB |
testcase_13 | AC | 431 ms
14,332 KB |
testcase_14 | AC | 254 ms
13,428 KB |
testcase_15 | AC | 292 ms
13,484 KB |
testcase_16 | AC | 222 ms
13,456 KB |
testcase_17 | AC | 119 ms
12,496 KB |
testcase_18 | AC | 131 ms
12,576 KB |
testcase_19 | AC | 276 ms
13,492 KB |
testcase_20 | AC | 608 ms
15,072 KB |
testcase_21 | AC | 571 ms
15,072 KB |
testcase_22 | AC | 578 ms
15,136 KB |
testcase_23 | AC | 608 ms
15,152 KB |
testcase_24 | AC | 601 ms
15,068 KB |
testcase_25 | AC | 561 ms
15,208 KB |
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } constexpr ll mod=998244353; ll mod_pow(ll a,ll b){ a%=mod; if(b==0)return 1; if(b==1)return a; ll res=mod_pow(a,b/2)%mod; res*=res; res%=mod; if(b%2)res*=a; return res%mod; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); const int N=2e6+1; vector<int> p,lp(N); // lp[i]:iの最小素因数 lp[0]=lp[1]=-1; for(int i=2;i<lp.size();i++){ if(lp[i]==0){ lp[i]=i; p.emplace_back(i); } for(int j=0;j<p.size() and p[j]<=lp[i] and i*p[j]<=lp.size();j++){ lp[i*p[j]]=p[j]; } } int n; cin >> n; ll r=1; map<int,int> res; for(int i=1;i<=n/2;i++){ int b=i,c=n-i; map<int,int> mp; while(b>1){ mp[lp[b]]++; b/=lp[b]; } swap(b,c); while(b>1){ mp[lp[b]]++; b/=lp[b]; } for(auto p:mp){ res[p.first]=max(res[p.first],p.second); } } for(auto p:res){ (r*=mod_pow(p.first,p.second))%=mod; } cout << r << endl; }