結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー bokusunnybokusunny
提出日時 2022-03-16 16:37:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 981 bytes
コンパイル時間 2,460 ms
コンパイル使用メモリ 203,420 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 21:43:30
合計ジャッジ時間 18,756 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 623 ms
4,372 KB
testcase_02 AC 621 ms
4,372 KB
testcase_03 AC 616 ms
4,372 KB
testcase_04 AC 615 ms
4,372 KB
testcase_05 AC 615 ms
4,372 KB
testcase_06 AC 615 ms
4,372 KB
testcase_07 AC 619 ms
4,372 KB
testcase_08 AC 616 ms
4,372 KB
testcase_09 AC 616 ms
4,372 KB
testcase_10 AC 271 ms
4,372 KB
testcase_11 AC 275 ms
4,372 KB
testcase_12 AC 275 ms
4,372 KB
testcase_13 AC 275 ms
4,372 KB
testcase_14 AC 275 ms
4,372 KB
testcase_15 AC 275 ms
4,372 KB
testcase_16 AC 276 ms
4,372 KB
testcase_17 AC 274 ms
4,372 KB
testcase_18 AC 274 ms
4,372 KB
testcase_19 AC 5 ms
4,372 KB
testcase_20 AC 5 ms
4,372 KB
testcase_21 AC 5 ms
4,372 KB
testcase_22 AC 4 ms
4,372 KB
testcase_23 AC 5 ms
4,372 KB
testcase_24 AC 5 ms
4,372 KB
testcase_25 AC 4 ms
4,372 KB
testcase_26 AC 5 ms
4,372 KB
testcase_27 AC 5 ms
4,372 KB
testcase_28 AC 2 ms
4,372 KB
testcase_29 AC 2 ms
4,372 KB
testcase_30 AC 2 ms
4,372 KB
testcase_31 AC 2 ms
4,372 KB
testcase_32 AC 2 ms
4,372 KB
testcase_33 AC 2 ms
4,372 KB
testcase_34 AC 2 ms
4,372 KB
testcase_35 AC 2 ms
4,372 KB
testcase_36 AC 2 ms
4,372 KB
testcase_37 AC 2 ms
4,372 KB
testcase_38 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

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

  vector<int> P;
  for (int p = 2; p <= 31; p++) {
    if (is_prime(p)) P.push_back(p);
  }

  for (long long y = x * 2; y <= x * 31; y += x) {
    long long xx = x;
    long long yy = y;

    long long cntx = 1;
    long long cnty = 1;
    for (auto &p : P) {
      int ex = 1;
      while (xx % p == 0) {
        xx /= p;
        ex++;
      }
      cntx *= ex;
      int ey = 1;
      while (yy % p == 0) {
        yy /= p;
        ey++;
      }
      cnty *= ey;
    }

    if ((cnty >> 1) == cntx) {
      cout << y << endl;
      return;
    }
  }

  assert(false);
}

int main() {
  bokusunny;

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

  return 0;
}
0