結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
wgrape
|
| 提出日時 | 2023-10-31 14:10:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 223 ms / 2,000 ms |
| コード長 | 420 bytes |
| 記録 | |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 127,808 KB |
| 最終ジャッジ日時 | 2024-09-25 17:39:26 |
| 合計ジャッジ時間 | 5,227 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
N,D = map(int,input().split())
from collections import defaultdict
# x^2 + y^2で作れる数を全列挙
XY = [0] * ((N ** 2) * 2 + 1)
for x in range(1, N + 1):
for y in range(1, N + 1):
XY[x ** 2 + y ** 2] += 1
ans = 0
for z in range(1, N + 1):
for w in range(1, N + 1):
target = D - (z ** 2 - w ** 2)
if 0 <= target <= (N ** 2) * 2:
ans += XY[target]
print(ans)
wgrape