結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー wolgnikwolgnik
提出日時 2021-07-21 22:21:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,486 bytes
コンパイル時間 1,318 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 77,948 KB
最終ジャッジ日時 2023-09-24 18:26:52
合計ジャッジ時間 9,712 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 259 ms
77,364 KB
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 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 74 ms
71,296 KB
testcase_29 AC 72 ms
71,020 KB
testcase_30 AC 74 ms
71,436 KB
testcase_31 AC 73 ms
71,164 KB
testcase_32 AC 72 ms
71,208 KB
testcase_33 AC 72 ms
71,484 KB
testcase_34 AC 71 ms
71,356 KB
testcase_35 WA -
testcase_36 AC 72 ms
71,456 KB
testcase_37 AC 71 ms
71,280 KB
testcase_38 AC 73 ms
71,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

class sieve:
  def __init__(self, n):
    self.n = n
    self.sv = [1] * (n + 1)
    self.sv[0] = 0
    self.sv[1] = 0
    self.minp = [n] * (n + 1)
    for i in range(2, n + 1):
      if self.sv[i]:
        self.minp[i] = i
        for j in range(i * 2, n + 1, i):
          self.sv[j] = 0
          self.minp[j] = min(self.minp[j], i)
  def isprime(self, x):
    if x > self.n:
      return False
    return self.sv[x] == 1
  def factorize(self, x):
    if self.sv[x]: return [(x, 1)]
    res = []
    while x > 1:
      p = self.minp[x]
      c = 0
      while x % p == 0:
        x //= p
        c += 1
      res.append((p, c))
    return res
  def modlcm(self, a, mod):
    res = [0] * (self.n + 1)
    ex = set()
    for i in range(len(a)):
      f = self.factorize(a[i])
      for j in f:
        if j > self.n:
          ex.add(j)
          continue
        res[j] = max(f.count(j), res[j])
    rres = 1
    for i in range(self.n + 1):
      if res[i] != 0:
        rres *= pow(i, res[i], mod)
        rres %= mod
    for i in ex:
      rres *= i
      rres %= mod
    return rres

sv = sieve(10 ** 2)
primes = []
for x in range(10 ** 2):
  if sv.isprime(x): primes.append(x)


for _ in range(int(input())):
  x = int(input())
  res = 10 ** 20
  for p in primes:
    if x % p: res = min(res, x * p)
    else:
      t = x
      c = 0
      while t % p == 0:
        t //= p
        c += 1
      res = min(res, x * p ** (c + 1))
  print(res)
0