結果

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

ソースコード

diff #

import math
def issqrt(n):
    x = int(round(math.sqrt(n)))
    return ((x * x) == n, x)
cnt = 0
N = int(input())
N2 = N * N
div = [x for x in range(1,N+1) if N2 % x == 0]
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