結果

問題 No.1143 面積Nの三角形
ユーザー mkawa2mkawa2
提出日時 2021-06-04 15:20:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 329 ms / 800 ms
コード長 1,680 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 78,196 KB
最終ジャッジ日時 2023-08-12 03:47:12
合計ジャッジ時間 6,237 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,804 KB
testcase_01 AC 76 ms
71,680 KB
testcase_02 AC 80 ms
76,212 KB
testcase_03 AC 86 ms
76,804 KB
testcase_04 AC 75 ms
71,884 KB
testcase_05 AC 85 ms
76,620 KB
testcase_06 AC 92 ms
76,976 KB
testcase_07 AC 119 ms
77,832 KB
testcase_08 AC 116 ms
77,548 KB
testcase_09 AC 127 ms
77,804 KB
testcase_10 AC 103 ms
77,588 KB
testcase_11 AC 200 ms
77,728 KB
testcase_12 AC 234 ms
77,844 KB
testcase_13 AC 226 ms
78,164 KB
testcase_14 AC 87 ms
76,780 KB
testcase_15 AC 73 ms
71,580 KB
testcase_16 AC 311 ms
78,080 KB
testcase_17 AC 329 ms
78,196 KB
testcase_18 AC 303 ms
78,024 KB
testcase_19 AC 286 ms
77,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
# md = 10**9+7

def pf(a):
    pp, ee = [], []
    for p in range(2, a+1):
        if p**2 > a: break
        e = 0
        while a%p == 0:
            a //= p
            e += 1
        if e:
            pp.append(p)
            ee.append(e)
    if a > 1:
        pp.append(a)
        ee.append(1)
    return pp, ee

n = II()
pp, ee = pf(n)
dd = [1]
for p, e in zip(pp, ee):
    s = p
    nd = []
    for _ in range(e*2):
        for d in dd:
            nd.append(d*s)
        s *= p
    dd += nd
dd.sort()
# print(len(dd),dd)

def floor_sqrt(x):
    # print(x)
    a = round(x**0.5-0.45)+1
    while a**2 > x: a -= 1
    return a

n2 = n**2
ans = 0
for i, x in enumerate(dd):
    for y in dd[:i+1]:
        if x*y >= n2: break
        if n2//x%y: continue
        b = x+y
        c = -n2//x//y
        r = floor_sqrt(b**2-4*c)
        if r**2 != b**2-4*c: continue
        z = -b+r
        if z <= 0 or z > y*2 or z & 1: continue
        # print(x,y,z//2)
        ans += 1
print(ans)
0