結果

問題 No.864 四方演算
ユーザー roarisroaris
提出日時 2019-08-17 14:30:39
言語 PyPy3
(7.3.11)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 564 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 76,400 KB
最終ジャッジ日時 2023-07-24 08:10:20
合計ジャッジ時間 4,948 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,664 KB
testcase_01 WA -
testcase_02 AC 81 ms
76,052 KB
testcase_03 AC 84 ms
75,984 KB
testcase_04 AC 84 ms
75,936 KB
testcase_05 AC 81 ms
75,832 KB
testcase_06 AC 85 ms
76,220 KB
testcase_07 AC 84 ms
76,124 KB
testcase_08 AC 82 ms
76,364 KB
testcase_09 AC 76 ms
75,888 KB
testcase_10 AC 78 ms
75,804 KB
testcase_11 AC 75 ms
76,056 KB
testcase_12 AC 81 ms
76,152 KB
testcase_13 AC 79 ms
76,020 KB
testcase_14 AC 75 ms
76,016 KB
testcase_15 AC 87 ms
76,084 KB
testcase_16 AC 84 ms
76,320 KB
testcase_17 AC 85 ms
76,088 KB
testcase_18 AC 86 ms
76,400 KB
testcase_19 AC 80 ms
76,088 KB
testcase_20 AC 84 ms
76,256 KB
testcase_21 AC 84 ms
76,216 KB
testcase_22 AC 83 ms
76,304 KB
testcase_23 AC 75 ms
76,144 KB
testcase_24 AC 82 ms
75,872 KB
testcase_25 AC 76 ms
75,968 KB
testcase_26 AC 82 ms
76,132 KB
testcase_27 AC 69 ms
71,516 KB
testcase_28 AC 69 ms
71,752 KB
testcase_29 AC 69 ms
71,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import ceil

N = int(input())
K = int(input())
ans = 0

for i in range(1, int(K**0.5)+1):
    if K % i == 0:
        P, Q = i, K // i
        
        if N >= P - 1 and N >= Q - 1:
            add = 2 * (P - 1) * (Q - 1)
        elif N >= P - 1 and Q - 2 >= N >= ceil(Q / 2):
            add = 2 * (P - 1) * (2 * N - Q + 1)
        elif P - 2 >= N >= ceil(P / 2) and N >= Q - 1:
            add = 2 * (2 * N - P + 1) * (Q - 1)
        else:
            add = 0
            
        if P == Q:
            add //= 2
        
        ans += add

print(ans)
0