結果

問題 No.1143 面積Nの三角形
ユーザー tamato
提出日時 2020-07-31 23:18:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,580 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 82,564 KB
実行使用メモリ 82,600 KB
最終ジャッジ日時 2024-07-06 21:28:29
合計ジャッジ時間 7,709 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 -- * 1
other AC * 8 TLE * 3 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    NN = 16*N*N
    memo = {}
    def divisors(n):
        if n in memo:
            return memo[n]

        ret = []
        for i in range(1, n+1):
            if i*i > n:
                break
            if n % i == 0:
                ret.append(i)
                ret.append(n // i)
        if ret[-1] * ret[-1] == n:
            ret.pop()
        ret.sort(reverse=True)
        memo[n] = ret
        return ret

    ans = 0
    div = divisors(NN)
    for L in div:
        if L**4 < NN:
            break
        ABC = NN // L
        #divABC = divisors(ABC)
        for A in div:
            if ABC % A:
                continue
            if A**3 < ABC:
                break
            if A%2 != L%2:
                continue
            BC = ABC // A
            #divBC = divisors(BC)
            for B in div:
                if BC%B:
                    continue
                if B**2 < BC:
                    break
                C = BC // B
                if B%2 != L%2:
                    continue
                if C%2 != L%2:
                    continue

                # check
                if not A >= B >= C:
                    continue
                a = (L-A) // 2
                b = (L-B) // 2
                c = (L-C) // 2
                if not L == a+b+c:
                    continue
                if a + b <= c:
                    continue
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()
0