結果
問題 |
No.1529 Constant Lcm
|
ユーザー |
![]() |
提出日時 | 2021-06-04 22:33:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 855 bytes |
コンパイル時間 | 2,738 ms |
コンパイル使用メモリ | 200,512 KB |
最終ジャッジ日時 | 2025-01-22 02:13:47 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 TLE * 15 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; const int MOD=998244353; map<ll,ll> prime_factor(ll x){ map<ll,ll> res; for(ll i=2;i*i<=x;i++){ while(x%i==0){ res[i]++; x/=i; } } if(x!=1) res[x]++; return res; } ll modpow(ll x,ll n){ ll ans=1; while(n){ if(n&1) ans=ans*x%MOD; x=x*x%MOD; n/=2; } return ans; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; map<ll,ll> M; for(int i=1;i<=n/2;i++){ ll x=i; ll y=n-i; map<ll,ll> m=prime_factor(x*y); for(auto t:m){ M[t.first]=max(M[t.first],t.second); } } ll ans=1; for(auto t:M){ ans=ans*modpow(t.first,t.second)%MOD; } cout<<ans<<endl; return 0; }