結果

問題 No.847 Divisors of Power
ユーザー mkawa2mkawa2
提出日時 2019-07-05 22:27:50
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 733 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 265,780 KB
最終ジャッジ日時 2024-04-16 07:44:32
合計ジャッジ時間 7,357 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,296 KB
testcase_01 AC 41 ms
52,896 KB
testcase_02 AC 50 ms
58,664 KB
testcase_03 AC 40 ms
52,828 KB
testcase_04 AC 60 ms
65,288 KB
testcase_05 AC 47 ms
59,024 KB
testcase_06 AC 45 ms
58,668 KB
testcase_07 AC 42 ms
53,916 KB
testcase_08 AC 45 ms
59,780 KB
testcase_09 AC 47 ms
59,424 KB
testcase_10 AC 51 ms
61,692 KB
testcase_11 AC 69 ms
70,388 KB
testcase_12 AC 43 ms
54,396 KB
testcase_13 AC 68 ms
70,536 KB
testcase_14 AC 58 ms
66,856 KB
testcase_15 AC 1,853 ms
239,180 KB
testcase_16 AC 45 ms
58,904 KB
testcase_17 AC 46 ms
59,300 KB
testcase_18 AC 76 ms
73,868 KB
testcase_19 AC 107 ms
77,744 KB
testcase_20 AC 46 ms
59,800 KB
testcase_21 AC 529 ms
123,036 KB
testcase_22 AC 45 ms
59,844 KB
testcase_23 AC 45 ms
59,684 KB
testcase_24 TLE -
testcase_25 AC 46 ms
59,020 KB
testcase_26 AC 40 ms
53,612 KB
testcase_27 AC 45 ms
59,088 KB
testcase_28 AC 43 ms
53,940 KB
testcase_29 AC 42 ms
54,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *
n,k,m=map(int,input().split())
if n==1:
    print(1)
    exit()
tei=[]
sis=[]
cnt=0
while n%2==0:
    n//=2
    cnt+=1
if cnt:
    tei=[2]
    sis=[cnt*k]
i=3
while i**2<=n:
    cnt=0
    while n%i==0:
        cnt+=1
        n//=i
    if cnt:
        tei+=[i]
        sis+=[cnt*k]
    i+=2
if n>1:
    tei+=[n]
    sis+=[k]
#print(sis)
#print(tei)
kos=len(tei)
hp=[]
a=[0]*kos
heappush(hp,[1]+a)
used=set()
used.add(tuple(a))
cnt=0
while 1:
    y,*a=heappop(hp)
    if y>m:break
    for i in range(kos):
        if a[i]==sis[i]:continue
        ny=y*tei[i]
        na=a[:]
        na[i]+=1
        ta=tuple(na)
        if ta in used:continue
        heappush(hp,[ny]+na)
        used.add(ta)
    cnt+=1
print(cnt)
0