結果

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

ソースコード

diff #

"""

6 = 2 * 3
24 = 2*2*2*6

2*2

2->4

2倍を素因数分解する

A * B * C

最小の含まれない素因数は割と小さいはず
それ以下に関して、探索する

31以下

2*3*5*7*11*13*17*19*23*29*31
で、10個

この内、積で31未満の物

4
8
16
9
27
25


"""

from sys import stdin
import sys
from collections import deque

def Sieve(n): #n以下の素数全列挙(O(nloglogn)) retは素数が入ってる。divlisはその数字の素因数が一つ入ってる

    ret = []
    divlis = [-1] * (n+1) #何で割ったかのリスト(初期値は-1)
    
    flag = [True] * (n+1)
    flag[0] = False
    flag[1] = False

    ind = 2
    while ind <= n:

        if flag[ind]:
            ret.append(ind)

            ind2 = ind ** 2

            while ind2 <= n:
                flag[ind2] = False
                divlis[ind2] = ind
                ind2 += ind

        ind += 1

    return ret,divlis

plis,tmp = Sieve(32)
#print (plis)

tt = int(stdin.readline())

for loop in range(tt):

    X = int(stdin.readline())

    ans = float("inf")

    for i in range(1,32):

        NY = X * i

        XN = 1
        TX = X
        for p in plis:
            now = 1
            while TX % p == 0:
                now += 1
                TX //= p
            XN *= now

        YN = 1
        TY = NY
        for p in plis:
            now = 1
            while TY % p == 0:
                now += 1
                TY //= p
            YN *= now

        if YN == XN * 2 and NY % X == 0:
            ans = min(ans,NY)

    print (ans)
0