結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー buey_t
提出日時 2023-03-25 20:08:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,036 ms / 2,000 ms
コード長 2,686 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 90,988 KB
最終ジャッジ日時 2024-09-19 01:28:50
合計ジャッジ時間 17,057 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    '''
    Xになんか足していけばよさそうやけど
    約数の中で最小をかければいい
    オーダー死ぬのでは
    約数でない最小の素数をかければよい
    素数じゃなくても割り切れなければよい
    
    高速素因数分解やるかー
    
    各素因数で何回割れるか調べる
    約数の個数を調べる
    先に1~31までの素因数分解を済ませておく
    比を求める
    '''
    
    #[素因数, 何乗か]
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
    
        if temp!=1:
            arr.append([temp, 1])
    
        if arr==[]:
            arr.append([n, 1])
    
        return arr
    
    
    prime = [2,3,5,7,11,13,17,19,23,29,31]
    
    ls = [[0]*32 for _ in range(32)]
    for i in range(2,32):
        tmp = factorization(i)
        for p,e in tmp:
            ls[i][p] = e
    
    for _ in range(int(input())):
        X = int(input())
        
        s = X
        
        fact = [0]*32
        for p in prime:
            while X%p == 0:
                X //= p
                fact[p] += 1
        
        cnt = 1
        for p in prime:
            cnt *= fact[p]+1
        
        for i in range(2,32):
            cnt2 = cnt
            for p in prime:
                cnt2 //= fact[p]+1
                cnt2 *= fact[p]+ls[i][p]+1
            
            if cnt2 == cnt*2:
                print(s*i)
                break
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0