結果

問題 No.1529 Constant Lcm
ユーザー ytqm3ytqm3
提出日時 2021-07-22 13:44:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 3,000 ms
コード長 3,808 bytes
コンパイル時間 2,388 ms
コンパイル使用メモリ 204,092 KB
実行使用メモリ 7,516 KB
最終ジャッジ日時 2023-09-24 13:53:31
合計ジャッジ時間 3,857 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,336 KB
testcase_01 AC 14 ms
7,464 KB
testcase_02 AC 14 ms
7,332 KB
testcase_03 AC 14 ms
7,352 KB
testcase_04 AC 14 ms
7,392 KB
testcase_05 AC 14 ms
7,196 KB
testcase_06 AC 14 ms
7,256 KB
testcase_07 AC 14 ms
7,196 KB
testcase_08 AC 14 ms
7,424 KB
testcase_09 AC 14 ms
7,384 KB
testcase_10 AC 14 ms
7,512 KB
testcase_11 AC 14 ms
7,352 KB
testcase_12 AC 14 ms
7,400 KB
testcase_13 AC 15 ms
7,516 KB
testcase_14 AC 14 ms
7,400 KB
testcase_15 AC 14 ms
7,228 KB
testcase_16 AC 14 ms
7,472 KB
testcase_17 AC 13 ms
7,236 KB
testcase_18 AC 15 ms
7,296 KB
testcase_19 AC 14 ms
7,400 KB
testcase_20 AC 15 ms
7,304 KB
testcase_21 AC 15 ms
7,220 KB
testcase_22 AC 15 ms
7,224 KB
testcase_23 AC 15 ms
7,356 KB
testcase_24 AC 15 ms
7,424 KB
testcase_25 AC 14 ms
7,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
typedef long double f128;
using namespace std;

template<u64 mod>
struct modint{
  u64 val;
  constexpr modint(const i64 x=0) noexcept:val((x%i64(mod)+i64(mod))%i64(mod)){}
  constexpr u64 get_mod() const noexcept{
    return mod;
  }
  constexpr modint operator+(const modint rhs) const noexcept{
    return modint(*this)+=rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept{
    return modint(*this)-=rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept{
    return modint(*this)*=rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept{
    return modint(*this)/=rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept{
    val+=rhs.val;
    val-=((val>=mod)?mod:0);
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept{
    val+=((val<rhs.val)?mod:0);
    val-=rhs.val;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept{
    val=val*rhs.val%mod;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept{
    u64 exp=mod-2;
    while(exp){
      if(exp&1){
        (*this)*=rhs;
      }
      rhs*=rhs;
      exp>>=1;
    }
    return *this;
  }
  friend constexpr ostream &operator<<(ostream &os,const modint &x) noexcept{
    return os<<(x.val);
  }
  friend constexpr istream &operator>>(istream &is,modint &x) noexcept{
    u64 t;
    is>>t;
    x=t;
    return is;
  }
};

void scan(){}

template<typename T,class... Args>
void scan(T& n,Args&... args){
  cin>>n;
  scan(args...);
}

template<typename T>
void scanall(T start,T end){
  for(;start!=end;++start){
    scan(*start);
  }
}

void print(){}

template<typename T,class... Args>
void print(T n,Args... args){
  cout<<n;
  print(args...);
}

template<typename T>
void println(T n){
  cout<<n<<endl;
}

template<typename T,class... Args>
void println(T n,Args... args){
  cout<<n<<' ';
  println(args...);
}

template<typename T>
void printall(T start,T end){
  if(start!=end){
    cout<<(*start);
    for(++start;start!=end;++start){
      cout<<' '<<(*start);
    }
  }
  cout<<endl;
}

template<typename T>
void chmax(T& n,T m){
  n=max(n,m);
}

template<typename T>
void chmin(T& n,T m){
  n=min(n,m);
}

template<typename T,typename U>
T power(T a,U n){
  T res=1;
  while(n){
    res*=((n&1)?a:1);
    a*=a;
    n>>=1;
  }
  return res;
}

i64 power(i64 a,i64 n,i64 m){
  i64 res=1%m;
  while(n){
    if(n&1){
      res=res*a%m;
    }
    a=a*a%m;
    n>>=1;
  }
  return res;
}

template<typename T>
struct combination{
  vector<T> fact,fact_inv;
  combination(int mx=3000000):fact(mx+1,1),fact_inv(mx+1,1){
    for(int i=2;i<=mx;++i){
      fact[i]=fact[i-1]*i;
    }
    fact_inv[mx]/=fact[mx];
    for(int i=mx;i>0;--i){
      fact_inv[i-1]=fact_inv[i]*i;
    }
  }
  template<typename U>
  T nCk(U n,U k){
    if(n<k||n<0||k<0){
      return 0;
    }
    return fact[n]*fact_inv[k]*fact_inv[n-k];
  }
};


void solve();

int main(){
  cout<<fixed<<setprecision(15);
  bool is_multicase=false;
  int T=1;
  if(is_multicase){
    scan(T);
  }
  for(int i=0;i<T;++i){
    solve();
  }
  return 0;
}

vector<i64> init(){
  vector<int> vec(1000001,1);
  for(int i=2;i<=1000000;++i){
    if(vec[i]==0){
      continue;
    }
    for(int j=2;j<=1000000/i;++j){
      vec[i*j]=0;
    }
  }
  vector<i64> res;
  res.reserve(100000);
  for(int i=2;i<=1000000;++i){
    if(vec[i]){
      res.emplace_back(i);
    }
  }
  return res;
}

void solve(){
  typedef modint<998244353> mint;
  vector<i64> prime_list=init();
  i64 N;
  scan(N);
  mint ans=1;
  for(i64 p:prime_list){
    i64 now=N;
    while(p<now&&now%p==0){
      now/=p;
      ans*=p*p;
    }
    i64 x=1;
    while(x*p<now){
      x*=p;
    }
    ans*=x;
  }
  println(ans);
}
0