結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー FromBooskaFromBooska
提出日時 2023-03-20 15:21:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 700 ms / 2,000 ms
コード長 2,060 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 78,604 KB
最終ジャッジ日時 2023-10-18 18:07:54
合計ジャッジ時間 14,032 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 700 ms
76,896 KB
testcase_01 AC 521 ms
77,180 KB
testcase_02 AC 508 ms
77,520 KB
testcase_03 AC 493 ms
77,028 KB
testcase_04 AC 503 ms
77,804 KB
testcase_05 AC 502 ms
77,548 KB
testcase_06 AC 517 ms
77,248 KB
testcase_07 AC 509 ms
77,704 KB
testcase_08 AC 507 ms
77,596 KB
testcase_09 AC 498 ms
77,504 KB
testcase_10 AC 441 ms
77,688 KB
testcase_11 AC 438 ms
77,424 KB
testcase_12 AC 431 ms
77,424 KB
testcase_13 AC 436 ms
77,424 KB
testcase_14 AC 486 ms
78,604 KB
testcase_15 AC 437 ms
77,688 KB
testcase_16 AC 445 ms
77,688 KB
testcase_17 AC 443 ms
77,688 KB
testcase_18 AC 465 ms
78,316 KB
testcase_19 AC 106 ms
77,068 KB
testcase_20 AC 110 ms
77,204 KB
testcase_21 AC 112 ms
77,288 KB
testcase_22 AC 114 ms
77,036 KB
testcase_23 AC 121 ms
76,988 KB
testcase_24 AC 112 ms
77,268 KB
testcase_25 AC 116 ms
76,976 KB
testcase_26 AC 108 ms
77,080 KB
testcase_27 AC 115 ms
76,972 KB
testcase_28 AC 43 ms
55,828 KB
testcase_29 AC 42 ms
55,828 KB
testcase_30 AC 42 ms
55,828 KB
testcase_31 AC 43 ms
55,828 KB
testcase_32 AC 43 ms
55,828 KB
testcase_33 AC 42 ms
55,828 KB
testcase_34 AC 44 ms
55,828 KB
testcase_35 AC 41 ms
55,828 KB
testcase_36 AC 44 ms
55,828 KB
testcase_37 AC 44 ms
55,828 KB
testcase_38 AC 43 ms
55,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 約数の個数は素因数の乗数+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
0