結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー bokusunny
提出日時 2022-02-12 22:30:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 960 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 196,264 KB
最終ジャッジ日時 2025-01-27 22:51:13
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define bokusunny ios::sync_with_stdio(false), cin.tie(nullptr);

bool is_prime(long long x) {
  if (x == 1) return false;

  long long i = 2;
  while (i * i <= x) {
    if (x % i == 0) return false;
    i++;
  }
  return true;
}

void solve() {
  int T;
  cin >> T;
  vector<int> Primes;
  for (int i = 2; i < 60; i++) {
    if (is_prime(i)) Primes.emplace_back(i);
  }
  int sz = (int)Primes.size();
  while (T--) {
    long long x;
    cin >> x;
    long long xx = x;

    vector<int> Cnt(sz);
    for (int i = 0; i < sz; i++) {
      while (x % Primes[i] == 0) {
        Cnt[i]++;
        x /= Primes[i];
      }
    }

    const int inf = 100;
    long long mul = inf;
    for (int i = 0; i < sz; i++) {
      long long tmp = 1;
      for (int j = 0; j <= Cnt[i]; j++) tmp *= Primes[i];
      mul = min(mul, tmp);
    }
    cout << xx * mul << endl;
  }
}

int main() {
  bokusunny;
  solve();

  return 0;
}
0