結果

問題 No.1611 Minimum Multiple with Double Divisors
コンテスト
ユーザー bokusunny
提出日時 2022-03-16 15:34:39
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 959 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,948 ms
コンパイル使用メモリ 209,872 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-06-25 13:30:26
合計ジャッジ時間 6,377 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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() {
  long long x;
  cin >> x;

  const long long INFLL = 1LL << 60;
  long long ans = INFLL;

  for (int p = 2; p <= 1000; p++) {
    if (!is_prime(p)) continue;

    if (x % p == 0) {
      long long xx = x;
      int ex = 0;
      while (xx % p == 0) {
        ex++;
        xx /= p;
      }
      long long tmp = x;
      for (int t = 0; t <= ex; t++) {
        if (tmp >= INFLL / p) {
          tmp = INFLL;
          break;
        }
        tmp *= p;
      }
      ans = min(ans, tmp);
    } else {
      ans = min(ans, x * p);
      break;
    }
  }

  cout << ans << endl;
}

int main() {
  bokusunny;

  int t;
  cin >> t;
  while (t--) solve();

  return 0;
}
0