結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2022-04-01 14:21:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,199 ms / 2,000 ms
コード長 1,336 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 79,744 KB
最終ジャッジ日時 2024-04-29 22:09:22
合計ジャッジ時間 15,114 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,199 ms
79,744 KB
testcase_01 AC 582 ms
78,660 KB
testcase_02 AC 566 ms
78,776 KB
testcase_03 AC 553 ms
78,736 KB
testcase_04 AC 553 ms
79,292 KB
testcase_05 AC 555 ms
78,900 KB
testcase_06 AC 539 ms
78,976 KB
testcase_07 AC 549 ms
78,944 KB
testcase_08 AC 540 ms
78,904 KB
testcase_09 AC 543 ms
79,164 KB
testcase_10 AC 392 ms
78,976 KB
testcase_11 AC 403 ms
78,848 KB
testcase_12 AC 402 ms
78,564 KB
testcase_13 AC 403 ms
78,720 KB
testcase_14 AC 405 ms
78,720 KB
testcase_15 AC 402 ms
78,848 KB
testcase_16 AC 403 ms
78,592 KB
testcase_17 AC 403 ms
78,720 KB
testcase_18 AC 398 ms
78,972 KB
testcase_19 AC 94 ms
76,672 KB
testcase_20 AC 91 ms
76,800 KB
testcase_21 AC 96 ms
76,928 KB
testcase_22 AC 92 ms
76,928 KB
testcase_23 AC 88 ms
76,928 KB
testcase_24 AC 90 ms
77,056 KB
testcase_25 AC 88 ms
76,672 KB
testcase_26 AC 90 ms
77,056 KB
testcase_27 AC 88 ms
76,780 KB
testcase_28 AC 39 ms
52,864 KB
testcase_29 AC 39 ms
52,736 KB
testcase_30 AC 39 ms
52,864 KB
testcase_31 AC 40 ms
52,480 KB
testcase_32 AC 40 ms
52,864 KB
testcase_33 AC 40 ms
52,992 KB
testcase_34 AC 40 ms
52,736 KB
testcase_35 AC 39 ms
52,480 KB
testcase_36 AC 39 ms
52,480 KB
testcase_37 AC 38 ms
52,992 KB
testcase_38 AC 38 ms
52,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


# 指定した整数以下の素数を列挙。エラトステネスの篩
def eratosthenes(n):
    l0=list(range(2,n+1))
    l1=[1]*(n+1)
    l1[0]=0
    l1[1]=0
    for li in l0:
        if li>int(n**0.5):
            break
        if l1[li]==1:
            k=2
        while k*li<=n:
            l1[k*li]=0
            k+=1
    ret=[i for i,li in enumerate(l1) if li==1]
    return ret

# 素因数分解
def factorization(n,prime):
    arr = []
    temp = n
    for p in prime:
        if temp%p==0:
            cnt=0
            while temp%p==0:
                cnt+=1
                temp //= p
            arr.append([p, cnt])
        if temp==1:break
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    ps={p:q for p,q in arr}
    return ps
prime=eratosthenes(31)
prime.sort()
df={i:factorization(i,prime) for i in range(2,32)}
t=int(input())
xx=[int(input()) for _ in range(t)]
inf=float('inf')

for x in xx:
    ps=factorization(x,prime)
    for i in range(2,32):
        if i not in ps:ps[i]=0
    nx=1
    ans=inf
    for v in ps.values():nx*=v+1
    for i in range(2,32):
        for k,v in df[i].items():ps[k]+=v
        ny=1
        for v in ps.values():ny*=v+1
        if 2*nx==ny:
            ans=x*i
            break
        for k,v in df[i].items():ps[k]-=v
    print(ans)
0