結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー umezoumezo
提出日時 2021-07-21 23:16:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,144 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 207,980 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-24 19:46:28
合計ジャッジ時間 9,845 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
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 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:59:9: 警告: ‘tmp’ may be used uninitialized [-Wmaybe-uninitialized]
   59 |         if(p>=tmp){
      |         ^~
main.cpp:45:8: 備考: ‘tmp’ はここで定義されています
   45 |     ll tmp;
      |        ^~~

ソースコード

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;

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

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int MAX=100010;
  vector<int> prime(MAX,1);
  prime[0]=0,prime[1]=0;
  for(int i=2;i*i<=MAX;i++){
    if(!prime[i]) continue;
    for(int j=2*i;j<=MAX;j+=i) prime[j]=0;
  }

  int NUM=1000;
  vector<int> A;
  for(int i=2;i<=NUM;i++){
    if(prime[i]) A.push_back(i);
  }
  
  int t;
  cin>>t;
  while(t--){
    ll x;
    cin>>x;
    ll tmp;
    rep(i,(int)A.size()){
      if(x%A[i]!=0){
        tmp=A[i];
        break;
      }
    }
    map<ll,ll> m=prime_factor(x);
    for(auto z:m){
      if(z.first>=tmp) continue;
      ll p=z.first;
      bool b=true;
      rep(i,z.second+1){
        p*=z.first;
        if(p>=tmp){
          b=false;
          break;
        }
      }
      if(b) tmp=p;
    }
    cout<<x*tmp<<endl;
  }
  
  return 0;
}
0