結果

問題 No.1143 面積Nの三角形
ユーザー 37zigen37zigen
提出日時 2020-08-03 02:54:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 800 ms
コード長 608 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 77,632 KB
最終ジャッジ日時 2023-09-28 12:47:53
合計ジャッジ時間 3,570 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,140 KB
testcase_01 AC 76 ms
71,444 KB
testcase_02 AC 80 ms
75,644 KB
testcase_03 AC 84 ms
76,492 KB
testcase_04 AC 76 ms
71,564 KB
testcase_05 AC 84 ms
76,492 KB
testcase_06 AC 87 ms
76,720 KB
testcase_07 AC 97 ms
76,908 KB
testcase_08 AC 106 ms
76,700 KB
testcase_09 AC 105 ms
76,772 KB
testcase_10 AC 96 ms
76,564 KB
testcase_11 AC 136 ms
77,552 KB
testcase_12 AC 142 ms
77,260 KB
testcase_13 AC 145 ms
77,136 KB
testcase_14 AC 102 ms
76,388 KB
testcase_15 AC 75 ms
71,424 KB
testcase_16 AC 188 ms
77,404 KB
testcase_17 AC 180 ms
77,632 KB
testcase_18 AC 161 ms
77,184 KB
testcase_19 AC 170 ms
77,364 KB
権限があれば一括ダウンロードができます

ソースコード

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