結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー shotoyooshotoyoo
提出日時 2021-07-21 22:13:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,001 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 115,696 KB
最終ジャッジ日時 2023-09-24 18:05:02
合計ジャッジ時間 16,208 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 481 ms
115,540 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 AC 407 ms
113,232 KB
testcase_14 AC 406 ms
113,920 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 412 ms
113,824 KB
testcase_19 AC 241 ms
104,464 KB
testcase_20 AC 242 ms
104,244 KB
testcase_21 AC 242 ms
104,240 KB
testcase_22 AC 240 ms
104,272 KB
testcase_23 AC 245 ms
104,520 KB
testcase_24 AC 242 ms
104,420 KB
testcase_25 AC 243 ms
104,384 KB
testcase_26 AC 243 ms
104,248 KB
testcase_27 AC 241 ms
104,356 KB
testcase_28 AC 216 ms
103,340 KB
testcase_29 AC 214 ms
103,320 KB
testcase_30 AC 216 ms
103,216 KB
testcase_31 AC 217 ms
102,988 KB
testcase_32 AC 217 ms
103,132 KB
testcase_33 AC 213 ms
103,272 KB
testcase_34 AC 217 ms
103,164 KB
testcase_35 AC 219 ms
103,272 KB
testcase_36 AC 220 ms
103,356 KB
testcase_37 AC 219 ms
103,392 KB
testcase_38 AC 216 ms
103,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

def hurui(n):
    """線形篩
    pl: 素数のリスト
    mpf: iを割り切る最小の素因数
    """
    pl = []
    mpf = [None]*(n+1)
    for d in range(2,n+1):
        if mpf[d] is None:
            mpf[d] = d
            pl.append(d)
        for p in pl:
            if p*d>n or p>mpf[d]:
                break
            mpf[p*d] = p
    return pl, mpf
from collections import defaultdict
def factor(num):
    d = defaultdict(int)
    if num==1:
        d.update({1:1})
        return d
    while num>1:
        d[mpf[num]] += 1
        num //= mpf[num]
    return d
def fs(num):
    f = factor(num)
    ans = [1]
    for k,v in f.items():
        tmp = []
        for i in range(len(ans)):
            val = 1
            for _ in range(v):
                val *= k
                ans.append(ans[i]*val)
    return ans
def sub(x,p):
    res = 0
    while x%p==0:
        x //= p
        res += 1
    return res

pl, mpf = hurui(10**6)
t = int(input())
ans = []
for i in range(t):
    x = int(input())
    for p in pl:
        if x%p!=0:
            res = p
            break
    else:
        assert 0
    m = 25
    count = [-1]*m # 回数がiの素数の最小
    for i in range(m)[::-1]:
        v = sub(x,pl[i])
        count[v] = pl[i]
    for i in range(1,m):
        if count[i]==-1:
            continue
        res = min(res, pow(count[i], i+1))
    r = 1
    for l in range(1, m):
        if r<l:
            r = l
        if count[l]==-1:
            continue
        while r+1<m and count[r+1]>=0:
            r += 1
        if r>=2*l:
            val = 1
            for i in range(l, 2*l+1):
                assert count[i]>0
                val *= count[i]
            res = min(res, val)
    ans.append(res*x)
write("\n".join(map(str, ans)))
0