結果

問題 No.1626 三角形の構築
ユーザー ayaoniayaoni
提出日時 2021-07-23 22:40:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,805 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,784 KB
実行使用メモリ 66,356 KB
最終ジャッジ日時 2024-04-20 15:53:20
合計ジャッジ時間 2,377 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,052 KB
testcase_01 AC 48 ms
62,868 KB
testcase_02 AC 36 ms
52,528 KB
testcase_03 AC 35 ms
52,780 KB
testcase_04 AC 36 ms
53,680 KB
testcase_05 AC 37 ms
52,460 KB
testcase_06 AC 36 ms
53,960 KB
testcase_07 AC 49 ms
62,196 KB
testcase_08 AC 46 ms
62,780 KB
testcase_09 AC 49 ms
63,160 KB
testcase_10 AC 46 ms
61,648 KB
testcase_11 AC 48 ms
63,160 KB
testcase_12 AC 45 ms
61,716 KB
testcase_13 AC 47 ms
62,708 KB
testcase_14 AC 46 ms
61,984 KB
testcase_15 AC 48 ms
62,300 KB
testcase_16 AC 53 ms
65,036 KB
testcase_17 AC 49 ms
64,172 KB
testcase_18 AC 47 ms
62,580 KB
testcase_19 AC 46 ms
62,140 KB
testcase_20 AC 48 ms
62,908 KB
testcase_21 AC 49 ms
63,840 KB
testcase_22 AC 52 ms
62,204 KB
testcase_23 AC 53 ms
66,356 KB
testcase_24 AC 50 ms
63,384 KB
testcase_25 AC 35 ms
54,308 KB
testcase_26 AC 43 ms
60,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import floor,sqrt
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


t = I()
for _ in range(t):
    S,T = MI()
    U = 2*S**2
    if U % T != 0 or T % 2 == 1:
        print(0)
        continue
    ANS = set()
    U //= T
    for d in range(1,int(U**(1/3))+1):
        if U % d == 0:
            c = T//2-d
            if c <= 0 or c > 10**9:
                break
            V = U//d
            p = T//2+d
            q = V+T//2*d
            if p**2-4*q < 0:
                continue
            a = floor((p-sqrt(p**2-4*q))//2)
            if a > 0 and a <= 10**9:
                b = p-a
                if b > 0 and b <= 10**9:
                    if a*b == q:
                        ans = [a,b,c]
                        ans.sort()
                        ANS.add(tuple(ans))
            if a+1 > 0 and a+1 < 10**9:
                b = p-(a+1)
                if b > 0 and b <= 10**9:
                    if (a+1)*b == q:
                        ans = [a+1,b,c]
                        ans.sort()
                        ANS.add(tuple(ans))
            if a-1 > 0 and a-1 < 10**9:
                b = p-(a-1)
                if b > 0 and b <= 10**9:
                    if (a-1)*b == q:
                        ans = [a-1,b,c]
                        ans.sort()
                        ANS.add(tuple(ans))
    print(len(ANS))
    for ans in ANS:
        a,b,c = ans
        print(a,b,c)
0