結果

問題 No.800 四平方定理
ユーザー uto_qkuto_qk
提出日時 2019-03-17 23:03:52
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 604 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 82,208 KB
最終ジャッジ日時 2023-09-22 09:41:13
合計ジャッジ時間 5,882 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
81,252 KB
testcase_01 AC 118 ms
77,512 KB
testcase_02 AC 128 ms
77,372 KB
testcase_03 AC 113 ms
77,504 KB
testcase_04 AC 117 ms
77,648 KB
testcase_05 AC 125 ms
77,640 KB
testcase_06 AC 122 ms
77,516 KB
testcase_07 AC 121 ms
77,488 KB
testcase_08 AC 95 ms
76,696 KB
testcase_09 AC 136 ms
77,604 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 #

import math as ma
N, D = map(int,input().split())
ans = 0
for x in range(1,N+1):
    for y in range(x,N+1):
        if (x**2 + y**2 - D) % 4 == 2:
            continue
        for z in range(y,N+1):
            w = x**2 + y**2 + z**2 - D
            if w >= 1 and w <= N**2 and (w % 4 == 0 or w % 4 == 1):
                sq = int(ma.sqrt(w))
                if w == sq**2:
                    if x == y and y == z:
                        ans += 1
                    elif x == y or y == z or z == x:
                        ans += 3
                    else:
                        ans += 6
print(ans)
0