結果

問題 No.1529 Constant Lcm
ユーザー umezoumezo
提出日時 2021-06-04 22:33:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 855 bytes
コンパイル時間 2,401 ms
コンパイル使用メモリ 206,816 KB
実行使用メモリ 9,356 KB
最終ジャッジ日時 2023-08-12 15:32:34
合計ジャッジ時間 7,272 ms
ジャッジサーバーID
(参考情報)
judge7 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,768 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0