結果

問題 No.864 四方演算
ユーザー suika_p
提出日時 2019-08-17 18:06:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 721 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-09-25 10:50:05
合計ジャッジ時間 3,524 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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