結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー ytqm3ytqm3
提出日時 2021-07-22 12:49:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,544 ms / 2,000 ms
コード長 3,676 bytes
コンパイル時間 2,500 ms
コンパイル使用メモリ 202,140 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-07-26 15:48:39
合計ジャッジ時間 15,068 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,544 ms
4,384 KB
testcase_01 AC 491 ms
4,384 KB
testcase_02 AC 488 ms
4,380 KB
testcase_03 AC 494 ms
4,384 KB
testcase_04 AC 497 ms
4,384 KB
testcase_05 AC 500 ms
4,380 KB
testcase_06 AC 489 ms
4,380 KB
testcase_07 AC 489 ms
4,384 KB
testcase_08 AC 478 ms
4,384 KB
testcase_09 AC 489 ms
4,384 KB
testcase_10 AC 237 ms
4,384 KB
testcase_11 AC 269 ms
4,380 KB
testcase_12 AC 267 ms
4,380 KB
testcase_13 AC 265 ms
4,388 KB
testcase_14 AC 265 ms
4,384 KB
testcase_15 AC 265 ms
4,380 KB
testcase_16 AC 263 ms
4,380 KB
testcase_17 AC 264 ms
4,380 KB
testcase_18 AC 264 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 4 ms
4,384 KB
testcase_21 AC 5 ms
4,384 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 4 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,384 KB
testcase_32 AC 1 ms
4,388 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,384 KB
testcase_38 AC 1 ms
4,380 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;
  combination(int mx=3000000):fact(mx+1,1){
    for(int i=2;i<=mx;++i){
      fact[i]=fact[i-1]*i;
    }
  }
  template<typename U>
  T nCk(U n,U k){
    if(n<k||n<0||k<0){
      return 0;
    }
    return fact[n]/fact[k]/fact[n-k];
  }
};

void solve();

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

vector<i64> solve_sub(i64 X,const vector<i64>& p){
  vector<i64> res(12);
  for(size_t i=0;i<12;++i){
    i64 ex=1;
    while(X%p[i]==0){
      ex++;
      X/=p[i];
    }
    res[i]=ex;
  }
  return res;
}

//複数テストケース
void solve(){
  i64 X;
  scan(X);
  const vector<i64> p={2,3,5,7,11,13,17,19,23,29,31,37};
  vector<i64> Xpf=solve_sub(X,p);
  i64 prodX=1;
  for(int i=0;i<12;++i){
    prodX*=Xpf[i];
  }
  for(int i=2;i<=37;++i){
    vector<i64> Xipf=solve_sub(X*i,p);
    i64 prodXi=1;
    for(int i=0;i<12;++i){
      prodXi*=Xipf[i];
    }
    if(prodX*2==prodXi){
      println(X*i);
      return;
    }
  }
}
0