結果
| 問題 |
No.1529 Constant Lcm
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2021-04-29 01:47:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,299 bytes |
| コンパイル時間 | 997 ms |
| コンパイル使用メモリ | 83,848 KB |
| 実行使用メモリ | 13,636 KB |
| 最終ジャッジ日時 | 2024-10-10 10:17:07 |
| 合計ジャッジ時間 | 5,370 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 TLE * 1 -- * 15 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll=long long;
vector<pair<ll,ll>> Prime_Factorization(ll N) {
vector<pair<ll,ll>> R;
ll e=0;
while (N%2==0){
e++;
N/=2;
}
R.push_back({2,e});
e=0;
while (N%3==0){
e++;
N/=3;
}
R.push_back({3,e});
ll p=5,f=0;
while (p*p<=N) {
if (N % p==0){
ll e=0;
while (N % p == 0){
e++;
N/=p;
}
R.push_back({p,e});
}
p+=2+2*f;
f^=1;
}
if (N != 1) R.push_back({N, 1});
return R;
}
ll pow_mod(ll a,ll p,ll m){
ll x=1;
while (p){
if (p&1){
x*=a;
x%=m;
}
a*=a; a%=m;
p>>=1;
}
return x;
}
ll max(ll a, ll b){
if (a>b) return a;
else return b;
}
int main(){
ll N;
ll mod=998244353;
vector<pair<ll,ll>> R;
map <ll,ll> D;
cin >> N;
for (int i=1; 2*i<=(N+1); i++){
R=Prime_Factorization(i*(N-i));
for (auto x:R) D[x.first]=max(D[x.first],x.second);
}
ll a=1;
for (auto x:D){
a*=pow_mod(x.first,x.second,mod);
a%=mod;
}
cout << a << endl;
}
Kazun