結果
問題 |
No.800 四平方定理
|
ユーザー |
|
提出日時 | 2022-01-22 16:27:24 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 385 ms / 2,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 200,576 KB |
最終ジャッジ日時 | 2024-11-27 14:06:09 |
合計ジャッジ時間 | 7,516 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
N, D = map(int, input().split()) mx = 2 * pow(N, 2) def make_cnt(n, d=None): cnt = [0] * (mx + 1) for i in range(1, n+1): for j in range(1, n+1): if d is not None: tmp = pow(i, 2) - pow(j, 2) + d else: tmp = pow(i, 2) + pow(j, 2) if 0 < tmp < mx + 1: cnt[tmp] += 1 return cnt xy_cnt = make_cnt(N) wz_cnt = make_cnt(N, D) ans = 0 for i in range(1, mx+1): ans += xy_cnt[i] * wz_cnt[i] print(ans)