結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー tassei903
提出日時 2021-07-21 22:02:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,210 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,772 KB
実行使用メモリ 91,344 KB
最終ジャッジ日時 2024-07-17 18:30:12
合計ジャッジ時間 7,018 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other TLE * 1 -- * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes")
no = lambda :print("no");No = lambda :print("No")
#######################################################################

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

pl = [2,3,5,7,11,13,17,19,23,29,31,37,41]
dl = dict()
for i, x in enumerate(pl):
    dl[x] = i
    
z = len(pl)
T = ni()
from collections import defaultdict
for i in range(T):
    x = ni()
    if x==1:
        print(2)
        continue
    d = factorization(x)
    used = [False]*z
    ans = 10**14
    #print(d)
    for j,y in d:
        ans = min(ans, pow(j,y+1))
        if j<=41:
            used[dl[j]]=True
    for j in range(z):
        if not used[j]:
            ans = min(ans,pl[j])
            break
    print(x*ans)
0