結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー 👑 KazunKazun
提出日時 2021-07-21 22:27:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 1,406 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 86,584 KB
最終ジャッジ日時 2024-04-14 05:22:20
合計ジャッジ時間 7,623 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 313 ms
86,584 KB
testcase_01 AC 224 ms
85,548 KB
testcase_02 AC 221 ms
86,032 KB
testcase_03 AC 214 ms
85,048 KB
testcase_04 AC 211 ms
85,420 KB
testcase_05 AC 223 ms
85,300 KB
testcase_06 AC 212 ms
85,548 KB
testcase_07 AC 212 ms
85,416 KB
testcase_08 AC 224 ms
85,428 KB
testcase_09 AC 216 ms
85,200 KB
testcase_10 AC 137 ms
82,196 KB
testcase_11 AC 143 ms
83,332 KB
testcase_12 AC 146 ms
83,804 KB
testcase_13 AC 151 ms
83,912 KB
testcase_14 AC 148 ms
83,496 KB
testcase_15 AC 147 ms
84,268 KB
testcase_16 AC 151 ms
83,776 KB
testcase_17 AC 154 ms
83,532 KB
testcase_18 AC 154 ms
83,004 KB
testcase_19 AC 54 ms
65,724 KB
testcase_20 AC 53 ms
63,400 KB
testcase_21 AC 53 ms
63,268 KB
testcase_22 AC 53 ms
64,192 KB
testcase_23 AC 55 ms
64,712 KB
testcase_24 AC 54 ms
64,612 KB
testcase_25 AC 54 ms
64,140 KB
testcase_26 AC 55 ms
65,920 KB
testcase_27 AC 55 ms
64,828 KB
testcase_28 AC 42 ms
54,516 KB
testcase_29 AC 42 ms
54,364 KB
testcase_30 AC 42 ms
54,200 KB
testcase_31 AC 42 ms
55,260 KB
testcase_32 AC 42 ms
54,712 KB
testcase_33 AC 42 ms
54,212 KB
testcase_34 AC 42 ms
54,968 KB
testcase_35 AC 41 ms
54,480 KB
testcase_36 AC 45 ms
55,364 KB
testcase_37 AC 42 ms
54,924 KB
testcase_38 AC 43 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)

    if N&1==0:
        C=0
        while N&1==0:
            N>>=1
            C+=1
        R.append([2,C])

    if N%3==0:
        C=0
        while N%3==0:
            N//=3
            C+=1
        R.append([3,C])

    k=5
    Flag=0
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=2+2*Flag
        Flag^=1

    if N!=1:
        R.append([N,1])

    return R

def solve(X):
    L=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]

    D=defaultdict(int)
    for y in L:
        if X%y!=0:
            break
        else:
            t=0
            x=X
            while x%y==0:
                t+=1
                x//=y
            D[y]=t

    for u in range(2,y):
        alpha=beta=1
        for p,e in S[u]:
            alpha*=1+D[p]
            beta *=1+D[p]+e

        if 2*alpha==beta:
            return u*X

    return y*X
#================================================
import sys
from collections import defaultdict

input=sys.stdin.readline
write=sys.stdout.write

S=[[]]
for a in range(1,101):
    S.append(Prime_Factorization(a))

T=int(input())

Ans=[]
for _ in range(T):
    X=int(input())
    Ans.append(solve(X))

write("\n".join(map(str,Ans)))
0