結果

問題 No.864 四方演算
ユーザー tnodinotnodino
提出日時 2022-05-28 15:26:05
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 122 ms / 1,000 ms
コード長 565 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 11,888 KB
実行使用メモリ 10,412 KB
最終ジャッジ日時 2023-10-20 23:10:24
合計ジャッジ時間 4,102 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,212 KB
testcase_01 AC 122 ms
10,220 KB
testcase_02 AC 92 ms
10,212 KB
testcase_03 AC 98 ms
10,212 KB
testcase_04 AC 108 ms
10,228 KB
testcase_05 AC 84 ms
10,212 KB
testcase_06 AC 108 ms
10,212 KB
testcase_07 AC 101 ms
10,212 KB
testcase_08 AC 90 ms
10,212 KB
testcase_09 AC 67 ms
10,212 KB
testcase_10 AC 62 ms
10,212 KB
testcase_11 AC 46 ms
10,212 KB
testcase_12 AC 93 ms
10,212 KB
testcase_13 AC 74 ms
10,212 KB
testcase_14 AC 49 ms
10,212 KB
testcase_15 AC 121 ms
10,212 KB
testcase_16 AC 95 ms
10,212 KB
testcase_17 AC 107 ms
10,256 KB
testcase_18 AC 98 ms
10,412 KB
testcase_19 AC 82 ms
10,232 KB
testcase_20 AC 111 ms
10,264 KB
testcase_21 AC 97 ms
10,260 KB
testcase_22 AC 89 ms
10,236 KB
testcase_23 AC 37 ms
10,228 KB
testcase_24 AC 82 ms
10,232 KB
testcase_25 AC 58 ms
10,236 KB
testcase_26 AC 90 ms
10,256 KB
testcase_27 AC 30 ms
10,212 KB
testcase_28 AC 30 ms
10,212 KB
testcase_29 AC 32 ms
10,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from math import sqrt
def divisor(N):
    ret = []
    for i in range(1,int(sqrt(N))+1):
        if N % i == 0:
            ret.append(i)
            if N // i != i:
                ret.append(N//i)
    ret.sort()
    return ret

N = int(input())
K = int(input())
div = divisor(K)
cnt = defaultdict(int)
for d in div:
    if d < 2 or N * 2 < d:
        continue
    if 2 <= d <= N + 1:
        cnt[d] = d - 1
    else:
        cnt[d] = N * 2 + 1 - d
ans = 0
for ac in div:
    bd = K // ac
    ans += cnt[ac] * cnt[bd]
print(ans)
0