結果
| 問題 | No.1611 Minimum Multiple with Double Divisors | 
| コンテスト | |
| ユーザー |  FromBooska | 
| 提出日時 | 2023-03-20 15:21:15 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 605 ms / 2,000 ms | 
| コード長 | 2,060 bytes | 
| コンパイル時間 | 176 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 78,664 KB | 
| 最終ジャッジ日時 | 2024-09-18 14:06:33 | 
| 合計ジャッジ時間 | 12,836 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 37 | 
ソースコード
# 約数の個数は素因数の乗数+1の積
# ということはその数に存在しない素因数倍であれば約数個数は2倍になる
# たとえば12であれば2と3は素数なので5倍の60のときに約数個数は2倍になる
# 存在しない素因数前に、存在する素因数の乗数+1を2倍にできる場合はそれでもok
# たとえば6=2**1*3**1で、4をかければ2**3となり約数個数は2倍になる
# 2*3*5*7*11*13*17*19*23*29*31 > 10**11なので、ここまでの素因数で存在しないものがあるはず
# 面倒なのは420=2**2*3*5*7, この倍数は6すると2と3の乗数が増えて倍になる
# そうであれば31までで全探索した方が早いか, TLEした
# 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[i] = cnt
    if temp!=1:
        arr[temp] = 1
    return arr
from collections import defaultdict
small_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
div_count_to31 = [{}, {}]
for i in range(2, 32):
    div_count_to31.append(factorization(i))
#print(div_count_to31)
T = int(input())
for i in range(T):
    X = int(input())
    X_copy = X
    X_factors = defaultdict(int)
    for p in small_primes:
        while X%p == 0:
            X_factors[p] += 1
            X //= p
    #print('X_factors', X_factors)
    count = 1
    for key in X_factors.keys():
        count *= X_factors[key]+1
    for j in range(2, 32):
        count2 = count
        for key2 in div_count_to31[j].keys():
            count2 //= X_factors[key2]+1
            count2 *= X_factors[key2]+div_count_to31[j][key2]+1
            
        #print('X_copy', X_copy, 'j', j, 'count', count, 'count2', count2)
        if count2 == count*2:
            print(X_copy*j)
            break
            
            
            
        