結果

問題 No.864 四方演算
ユーザー kohei2019kohei2019
提出日時 2022-05-04 13:46:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 1,000 ms
コード長 766 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 76,436 KB
最終ジャッジ日時 2023-09-16 16:16:22
合計ジャッジ時間 4,319 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,276 KB
testcase_01 AC 86 ms
75,484 KB
testcase_02 AC 79 ms
75,588 KB
testcase_03 AC 83 ms
75,500 KB
testcase_04 AC 85 ms
75,348 KB
testcase_05 AC 80 ms
75,592 KB
testcase_06 AC 83 ms
75,352 KB
testcase_07 AC 81 ms
75,312 KB
testcase_08 AC 80 ms
75,448 KB
testcase_09 AC 74 ms
75,584 KB
testcase_10 AC 77 ms
75,828 KB
testcase_11 AC 72 ms
75,580 KB
testcase_12 AC 79 ms
75,584 KB
testcase_13 AC 78 ms
75,564 KB
testcase_14 AC 73 ms
75,640 KB
testcase_15 AC 91 ms
75,528 KB
testcase_16 AC 82 ms
75,440 KB
testcase_17 AC 85 ms
75,828 KB
testcase_18 AC 91 ms
76,436 KB
testcase_19 AC 81 ms
75,404 KB
testcase_20 AC 86 ms
75,760 KB
testcase_21 AC 82 ms
75,592 KB
testcase_22 AC 86 ms
75,540 KB
testcase_23 AC 72 ms
75,568 KB
testcase_24 AC 81 ms
75,500 KB
testcase_25 AC 76 ms
75,628 KB
testcase_26 AC 83 ms
75,476 KB
testcase_27 AC 67 ms
71,240 KB
testcase_28 AC 69 ms
71,352 KB
testcase_29 AC 71 ms
71,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(N):#約数列挙O(√N)
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= N:
        if N % i == 0:
            lower_divisors.append(i)
            if i != N // i:
                upper_divisors.append(N//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N = int(input())
K = int(input())

if 4 > K:
    print(0)
    exit()

div = make_divisors(K)
ans = 0
for d in div:
    if d == 1 or d == K:
        continue
    d1 = d
    d2 = K//d
    if d1 % 2 == 0:
        cnt1 = max(0,min((N-d1//2)*2+1,d1-1))
    else:
        cnt1 = max(0,min((N-d1//2)*2,d1-1))
    if d2 % 2 == 0:
        cnt2 = max(0,min((N-d2//2)*2+1,d2-1))
    else:
        cnt2 = max(0,min((N-d2//2)*2,d2-1))
    ans += cnt1*cnt2
print(ans)
0