結果

問題 No.1143 面積Nの三角形
ユーザー 37zigen37zigen
提出日時 2020-08-03 02:58:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 800 ms
コード長 576 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 77,380 KB
最終ジャッジ日時 2023-09-28 12:52:41
合計ジャッジ時間 3,635 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,440 KB
testcase_01 AC 74 ms
71,384 KB
testcase_02 AC 80 ms
75,532 KB
testcase_03 AC 91 ms
76,812 KB
testcase_04 AC 79 ms
71,128 KB
testcase_05 AC 90 ms
76,684 KB
testcase_06 AC 91 ms
76,396 KB
testcase_07 AC 100 ms
76,788 KB
testcase_08 AC 108 ms
76,624 KB
testcase_09 AC 106 ms
76,764 KB
testcase_10 AC 98 ms
76,648 KB
testcase_11 AC 137 ms
77,344 KB
testcase_12 AC 138 ms
77,312 KB
testcase_13 AC 147 ms
77,356 KB
testcase_14 AC 102 ms
76,296 KB
testcase_15 AC 73 ms
71,304 KB
testcase_16 AC 181 ms
77,304 KB
testcase_17 AC 172 ms
77,380 KB
testcase_18 AC 161 ms
77,380 KB
testcase_19 AC 170 ms
77,088 KB
権限があれば一括ダウンロードができます

ソースコード

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