結果

問題 No.864 四方演算
ユーザー ryusukeryusuke
提出日時 2022-05-24 14:24:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 1,000 ms
コード長 582 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 81,868 KB
実行使用メモリ 60,120 KB
最終ジャッジ日時 2023-10-20 18:47:56
合計ジャッジ時間 2,944 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,696 KB
testcase_01 AC 52 ms
57,488 KB
testcase_02 AC 46 ms
57,488 KB
testcase_03 AC 48 ms
57,488 KB
testcase_04 AC 49 ms
57,488 KB
testcase_05 AC 46 ms
57,488 KB
testcase_06 AC 50 ms
57,488 KB
testcase_07 AC 48 ms
57,488 KB
testcase_08 AC 47 ms
57,488 KB
testcase_09 AC 43 ms
57,488 KB
testcase_10 AC 43 ms
57,488 KB
testcase_11 AC 41 ms
57,488 KB
testcase_12 AC 47 ms
57,488 KB
testcase_13 AC 45 ms
57,488 KB
testcase_14 AC 41 ms
57,488 KB
testcase_15 AC 52 ms
57,488 KB
testcase_16 AC 47 ms
57,488 KB
testcase_17 AC 51 ms
59,536 KB
testcase_18 AC 51 ms
60,120 KB
testcase_19 AC 46 ms
57,488 KB
testcase_20 AC 51 ms
59,536 KB
testcase_21 AC 50 ms
59,536 KB
testcase_22 AC 47 ms
57,488 KB
testcase_23 AC 39 ms
57,488 KB
testcase_24 AC 45 ms
57,488 KB
testcase_25 AC 42 ms
57,488 KB
testcase_26 AC 48 ms
59,536 KB
testcase_27 AC 36 ms
53,696 KB
testcase_28 AC 36 ms
53,696 KB
testcase_29 AC 36 ms
53,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisors(n: int) -> list:
    divisor = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisor.append(i)
            if i != n // i:
                divisor.append(n // i)

    divisor.sort()
    return divisor

n = int(input())
k = int(input())

div = divisors(k)
ans = 0
for ac in div:
    bd = k // ac
    
    if ac > 2 * n or bd > 2 * n:
        continue

    if ac <= n + 1:
        ac -= 1
    else:
        ac = 2 * n - ac + 1

    if bd <= n + 1:
        bd -= 1
    else:
        bd = 2 * n - bd + 1
    
    ans += ac * bd

print(ans)
0