結果

問題 No.864 四方演算
ユーザー kohei2019kohei2019
提出日時 2022-05-04 13:40:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 76,312 KB
最終ジャッジ日時 2023-09-16 16:09:10
合計ジャッジ時間 4,722 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 85 ms
75,088 KB
testcase_03 AC 89 ms
75,376 KB
testcase_04 AC 89 ms
75,092 KB
testcase_05 AC 83 ms
75,440 KB
testcase_06 AC 87 ms
75,236 KB
testcase_07 AC 86 ms
75,608 KB
testcase_08 AC 85 ms
75,236 KB
testcase_09 AC 81 ms
75,200 KB
testcase_10 AC 81 ms
75,100 KB
testcase_11 AC 77 ms
75,208 KB
testcase_12 AC 85 ms
75,272 KB
testcase_13 AC 82 ms
75,276 KB
testcase_14 AC 76 ms
75,508 KB
testcase_15 AC 90 ms
75,624 KB
testcase_16 AC 85 ms
75,352 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 78 ms
75,204 KB
testcase_24 WA -
testcase_25 AC 80 ms
75,252 KB
testcase_26 WA -
testcase_27 AC 71 ms
71,380 KB
testcase_28 AC 71 ms
71,320 KB
testcase_29 AC 71 ms
70,936 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 == 2:
        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 == 2:
        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