結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-02 22:04:00 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 870 bytes |
| 記録 | |
| コンパイル時間 | 209 ms |
| コンパイル使用メモリ | 84,988 KB |
| 実行使用メモリ | 70,392 KB |
| 最終ジャッジ日時 | 2026-05-26 22:12:07 |
| 合計ジャッジ時間 | 11,963 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 5 WA * 5 TLE * 1 -- * 19 |
ソースコード
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)