結果

問題 No.864 四方演算
ユーザー tcltk
提出日時 2021-06-10 06:34:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 157 ms / 1,000 ms
コード長 887 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 88,828 KB
最終ジャッジ日時 2024-11-29 10:26:52
合計ジャッジ時間 5,863 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """3
# 15
# """
# sys.stdin = io.StringIO(_INPUT)

def get_divisors(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]

def f(d):
    x = min(d, N)
    if max(1, d-x) <= min(x, d-1):
        return min(x, d-1) - max(1, d-x) + 1
    else:
        return 0

N = int(input())
K = int(input())
divs = get_divisors(K)
ans = 0
for d in divs:
    d1 = d
    d2 = K // d
    ans += f(d1) * f(d2)
print(ans)


0