結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2022-04-01 13:32:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,089 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,132 KB
実行使用メモリ 78,808 KB
最終ジャッジ日時 2024-04-29 21:15:42
合計ジャッジ時間 8,306 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
78,080 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 38 ms
52,480 KB
testcase_29 AC 37 ms
52,096 KB
testcase_30 AC 38 ms
52,480 KB
testcase_31 AC 37 ms
52,224 KB
testcase_32 AC 36 ms
52,608 KB
testcase_33 AC 36 ms
52,480 KB
testcase_34 AC 36 ms
52,608 KB
testcase_35 WA -
testcase_36 AC 38 ms
52,224 KB
testcase_37 AC 37 ms
52,480 KB
testcase_38 AC 38 ms
52,788 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:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
prime=eratosthenes(32)
prime.sort()
t=int(input())
xx=[int(input()) for _ in range(t)]
inf=float('inf')
for x in xx:
    ary=factorization(x,prime)
    ps={p:q for p,q in ary}
    # pow(p,ps[p]+1)
    ans=inf
    for p in prime:
        if p in ps:
            ans=min(ans,x*pow(p,ps[p]+1))
        else:
            ans=min(ans,x*p)
    print(ans)
0