結果

問題 No.1529 Constant Lcm
ユーザー inksamuraiinksamurai
提出日時 2021-06-04 23:49:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,909 bytes
コンパイル時間 1,002 ms
コンパイル使用メモリ 109,876 KB
実行使用メモリ 12,872 KB
最終ジャッジ日時 2024-04-30 14:25:09
合計ジャッジ時間 6,683 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip> 
#include <stdio.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define PI 3.14159265359
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (ll)(c).size()
#define mkp(a,b) make_pair(a,b)
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define rsz(a,n) a.resize(n)
#define pii pair <ll,ll>
#define rep(i,n) for(int i = 0 ; i < n ; i++) 
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(int i = x ; i < n ; i++)
#define vi vector <ll> 
#define vec(s) vector<s>
#define rsz(a,n) a.resize(n)
#define rszv(a,n,v) a.resize(n,v)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
//eodefine
 
const int max_n = 103002;
 
using namespace std;
const int mod=998244353;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint binpow(int a, int b) {  
  mint res = 1; 
  while (b) { 
  	if (b%2) res = res * a; a = a * a; b /= 2; 
  } 
  return res;
}

vec(pii) primefact[max_n];

int nmp[max_n],mp[max_n];

void merg(int x,int y) {
    for(auto p:primefact[x]) { nmp[p.fi]=0; }
    for(auto p:primefact[y]) { nmp[p.fi]=0; }
    
    for(auto p:primefact[x]) {
        nmp[p.fi]=p.se; 
    }
    for(auto p:primefact[y]) {
        nmp[p.fi]+=p.se;
    }
    for(auto p :primefact[x]) mp[p.fi]=max(mp[p.fi],nmp[p.fi]);
    for(auto p :primefact[y]) mp[p.fi]=max(mp[p.fi],nmp[p.fi]);
}

int main(){
fcin;
    int n;
    cin>>n;
    
    crep(i,1,n) {
        int x=i,y=x;
        for(int j=2;j<=sqrt(x);j++) {
            while(y%j==0) {
                int cnt=0;
                while(y%j==0) {y/=j; cnt++;}
                primefact[i].pb({j,cnt});
            }
        }
        if(y!=1) primefact[i].pb({y,1});
    }

    crep(i,1,n) {
        merg(i,n-i);
    }
    
    mint ans=1;

    crep(i,1,max_n-3){
        if(mp[i]==0)continue;
       ans *= binpow(i,mp[i]);
    }

    cout << ans.x << "\n";
/*
*/
 
    return 0;   
}
0