結果

問題 No.1626 三角形の構築
ユーザー 👑 tamatotamato
提出日時 2021-07-23 23:11:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,244 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 61,312 KB
最終ジャッジ日時 2024-04-20 16:03:43
合計ジャッジ時間 2,775 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,608 KB
testcase_01 AC 53 ms
60,416 KB
testcase_02 AC 41 ms
52,608 KB
testcase_03 AC 43 ms
52,864 KB
testcase_04 AC 42 ms
52,352 KB
testcase_05 AC 42 ms
52,352 KB
testcase_06 AC 42 ms
52,480 KB
testcase_07 AC 54 ms
60,928 KB
testcase_08 AC 55 ms
60,928 KB
testcase_09 AC 54 ms
60,544 KB
testcase_10 AC 55 ms
60,544 KB
testcase_11 AC 55 ms
60,800 KB
testcase_12 AC 50 ms
60,160 KB
testcase_13 AC 53 ms
60,288 KB
testcase_14 AC 53 ms
60,672 KB
testcase_15 AC 53 ms
60,160 KB
testcase_16 AC 54 ms
60,416 KB
testcase_17 AC 53 ms
60,800 KB
testcase_18 AC 54 ms
60,672 KB
testcase_19 AC 54 ms
60,544 KB
testcase_20 AC 53 ms
60,800 KB
testcase_21 AC 54 ms
60,928 KB
testcase_22 AC 54 ms
60,672 KB
testcase_23 AC 55 ms
61,048 KB
testcase_24 AC 63 ms
61,312 KB
testcase_25 AC 42 ms
52,480 KB
testcase_26 AC 51 ms
59,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
NMAX = 10**5

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

    for _ in range(int(input())):
        S, T = map(int, input().split())
        if T & 1:
            print(0)
            continue
        t = T // 2
        if (S * S) % t:
            print(0)
            continue
        U = S * S // t
        ans = []
        for A in range(1, NMAX):
            if (t - A) * 2 >= T:
                continue
            if A ** 3 > U:
                break
            if U % A:
                continue
            alpha = t - A
            beta = U // A
            D = alpha ** 2 - 4 * beta
            if D >= 0:
                d = int(sqrt(D) + 0.1)
                if d ** 2 == D:
                    if alpha & 1 == d & 1:
                        B = (alpha + d) // 2
                        C = (alpha - d) // 2
                        a = t - A
                        b = t - B
                        c = t - C
                        if a + b + c == T and a < b + c and max(a, b, c) == a:
                            ans.append((a, b, c))

        print(len(ans))
        for a, b, c in ans:
            print(a, b, c)


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