結果

問題 No.864 四方演算
ユーザー suika_psuika_p
提出日時 2019-08-17 18:06:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 117 ms / 1,000 ms
コード長 721 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 10,228 KB
最終ジャッジ日時 2023-10-26 02:49:49
合計ジャッジ時間 3,205 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,172 KB
testcase_01 AC 116 ms
10,176 KB
testcase_02 AC 87 ms
10,172 KB
testcase_03 AC 94 ms
10,172 KB
testcase_04 AC 104 ms
10,176 KB
testcase_05 AC 81 ms
10,172 KB
testcase_06 AC 104 ms
10,172 KB
testcase_07 AC 97 ms
10,172 KB
testcase_08 AC 87 ms
10,172 KB
testcase_09 AC 62 ms
10,172 KB
testcase_10 AC 57 ms
10,172 KB
testcase_11 AC 42 ms
10,172 KB
testcase_12 AC 88 ms
10,172 KB
testcase_13 AC 72 ms
10,172 KB
testcase_14 AC 45 ms
10,172 KB
testcase_15 AC 117 ms
10,172 KB
testcase_16 AC 92 ms
10,172 KB
testcase_17 AC 102 ms
10,180 KB
testcase_18 AC 94 ms
10,228 KB
testcase_19 AC 78 ms
10,176 KB
testcase_20 AC 106 ms
10,184 KB
testcase_21 AC 93 ms
10,184 KB
testcase_22 AC 85 ms
10,180 KB
testcase_23 AC 34 ms
10,176 KB
testcase_24 AC 79 ms
10,176 KB
testcase_25 AC 54 ms
10,180 KB
testcase_26 AC 86 ms
10,180 KB
testcase_27 AC 27 ms
10,172 KB
testcase_28 AC 26 ms
10,172 KB
testcase_29 AC 27 ms
10,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#約数を求める
def makeDivisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N = int(input())
K = int(input())

a = makeDivisor(K)

if K < 4:
    print(0)
    exit()
a.pop(0)
a.pop()

ans = 0

for i in range(len(a)):
    x = a[i]
    if x <= N + 1:
        cnt1 = x - 1
    elif N + 2 <= x <= 2 * N:
        cnt1 = 2 * N + 1 - x
    else:
        cnt1 = 0
    y = a[len(a)-1-i]
    if y <= N + 1:
        cnt2 = y - 1
    elif N + 2 <= y <= 2 * N:
        cnt2 = 2 * N + 1 - y
    else:
        cnt2 = 0
    ans += cnt1 * cnt2

print(ans)
0