結果
問題 | No.1529 Constant Lcm |
ユーザー |
![]() |
提出日時 | 2021-06-04 20:16:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2,799 ms / 3,000 ms |
コード長 | 1,555 bytes |
コンパイル時間 | 3,189 ms |
コンパイル使用メモリ | 187,276 KB |
最終ジャッジ日時 | 2025-01-21 21:42:07 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #include <list> #include <atcoder/all> #define popcount __builtin_popcount using namespace std; using namespace atcoder; typedef long long ll; typedef pair<int, int> P; using ull=unsigned long long; using mint=modint998244353; const int MAX=1000010; bitset<MAX> isprime; void sieve(){ for(int i=3; i<MAX; i++, i++) isprime[i]=1; isprime[2]=1; for(int i=3; i<MAX; i++){ if(isprime[i]){ for(int j=(i<<1); j<MAX; j+=i) isprime[j]=0; } } } map<int, int> mp[1000010]; int mx[1000010]; int main() { int n; cin>>n; sieve(); for(int i=1; i<n; i++){ if(!isprime[i]) continue; for(int j=i; j<n; j+=i){ int x=j, e=0; while(x%i==0){ e++; x/=i; } mp[j][i]+=e; mp[n-j][i]+=e; } } for(int i=1; i<n; i++){ for(auto p:mp[i]){ mx[p.first]=max(mx[p.first], p.second); } } mint ans=1; for(int i=1; i<n; i++){ if(!isprime[i]) continue; ans*=mint(i).pow(mx[i]); } cout<<ans.val()<<endl; return 0; }