結果

問題 No.800 四平方定理
ユーザー IJKTanabeIJKTanabe
提出日時 2019-09-02 22:04:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 80,776 KB
最終ジャッジ日時 2023-08-22 18:02:05
合計ジャッジ時間 16,724 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 407 ms
76,708 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 778 ms
76,384 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1,872 ms
76,332 KB
testcase_07 WA -
testcase_08 AC 1,900 ms
76,364 KB
testcase_09 AC 1,453 ms
76,372 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d = [int(i) for i in input().rstrip().split()]
sqr = [i**2 for i in range(n + 1)]
target_num_lis = [i + d for i in sqr]
max_num = target_num_lis[-1]
count = 0

for x in range(1, n + 1):
    sqr_x = sqr[x]
    if sqr_x > max_num: break
    for y in range(x, n + 1):
        sqr_xy = sqr_x + sqr[y]
        if sqr_xy > max_num: break
        for z in range(y, n + 1):
            sqr_xyz = sqr_xy + sqr[z]
            if  sqr_xyz in target_num_lis:
                w = target_num_lis.index(sqr_xyz)
                if x != y != z:
                    count += 6
                elif x == y == z:
                    count += 1
                else:
                    count +=3
                
                # print('x:{0} y:{1} z:{2} in w{3}'.format(x,y,z,w))
                # print('count = ' + str(count))
                # input()
print(count)
                
0