結果

問題 No.2417 Div Count
ユーザー SuzuxSuzux
提出日時 2023-08-12 14:51:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,384 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 22,612 KB
最終ジャッジ日時 2024-04-30 07:21:28
合計ジャッジ時間 3,983 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
11,008 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 26 ms
10,880 KB
testcase_03 AC 26 ms
10,880 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 WA -
testcase_06 AC 26 ms
10,880 KB
testcase_07 AC 26 ms
11,008 KB
testcase_08 AC 25 ms
10,880 KB
testcase_09 AC 25 ms
11,008 KB
testcase_10 AC 24 ms
10,880 KB
testcase_11 AC 25 ms
10,880 KB
testcase_12 AC 27 ms
10,880 KB
testcase_13 AC 27 ms
10,880 KB
testcase_14 AC 30 ms
10,880 KB
testcase_15 AC 26 ms
10,880 KB
testcase_16 WA -
testcase_17 AC 28 ms
10,880 KB
testcase_18 AC 27 ms
10,880 KB
testcase_19 AC 27 ms
10,880 KB
testcase_20 WA -
testcase_21 AC 26 ms
10,880 KB
testcase_22 AC 27 ms
10,880 KB
testcase_23 WA -
testcase_24 AC 27 ms
10,880 KB
testcase_25 WA -
testcase_26 AC 31 ms
11,264 KB
testcase_27 WA -
testcase_28 AC 31 ms
11,136 KB
testcase_29 AC 50 ms
12,032 KB
testcase_30 AC 51 ms
12,160 KB
testcase_31 AC 32 ms
11,008 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 73 ms
12,288 KB
testcase_35 WA -
testcase_36 AC 150 ms
16,000 KB
testcase_37 AC 158 ms
16,000 KB
testcase_38 AC 503 ms
22,612 KB
testcase_39 AC 237 ms
17,040 KB
testcase_40 AC 122 ms
13,184 KB
testcase_41 AC 92 ms
12,544 KB
testcase_42 AC 25 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n, k = list(map(int, input().split()))
maxA = n-k

primeSet = set()
primeList = [True] * int(3 + maxA ** 0.5)

primeList[1] = False
primeList[2] = True
primeSet.add(2)
for i in range(4, len(primeList), 2):
    primeList[i] = False

for i in range(3, len(primeList)):
    if primeList[i] == True:
        for j in range(i*2, len(primeList), i):
            primeList[j] = False
        primeSet.add(i)
# print(sorted(primeSet))
ans = 0
pFactor = defaultdict(lambda: 0)
cnt = 0
while maxA > 1:
    flag = False
    # print(pFactor)
    for p in primeSet:
        if maxA % p == 0:
            pFactor[p] += 1
            maxA //= p
            cnt += 1
            flag = True
            continue
    if cnt == 0:
        pFactor[maxA] += 1
    if not flag:
        break

facSet = set()

pKey = sorted(pFactor.keys())
# print(pKey)
def recurPrime(pIndex, n):
    if pIndex == len(pKey):
        facSet.add(n)
    else:
        for i2 in range(pFactor[pKey[pIndex]]+1):
            recurPrime(pIndex+1, n*(int(pKey[pIndex])**i2))

if len(pKey) > 0:
    for i in range(pFactor[pKey[0]]+1):
        recurPrime(1, pKey[0]**i)
else:
    if n == 1 and k == 0:
        ans = 1
    else:
        ans = 0

facRemove = set()
for f in facSet:
    if f <= k:
        facRemove.add(f)
facSet = facSet - facRemove

# print(facSet)
ans += len(facSet)
print(ans)
0