結果

問題 No.1143 面積Nの三角形
ユーザー 37zigen
提出日時 2020-08-03 02:54:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 800 ms
コード長 608 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2024-07-21 07:25:09
合計ジャッジ時間 2,494 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import math


def issqrt(n):
    x = int(round(math.sqrt(n)))
    return ((x * x) == n, x)
div = []
cnt = 0
N = int(input())
N2 = N * N
for i in range(1, N + 1):
    if N2 % i == 0:
        div.append(i)
for u in div:
    for v in div:
        if u > v or N2 % (u * v) != 0:
            continue
        n = N2 // u // v
        m = (u + v) * (u + v) + 4 * n
        f = issqrt(m)
        if not f[0]:
            continue
        m = f[1]
        if (-(u + v) + m) % 2 != 0:
            continue
        w = (-(u + v) + m) // 2
        if not (u <= v <= w):
            continue
        cnt += 1
print(cnt)
0