結果
問題 | No.152 貯金箱の消失 |
ユーザー |
|
提出日時 | 2022-11-30 17:18:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 641 ms / 5,000 ms |
コード長 | 485 bytes |
コンパイル時間 | 487 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 102,236 KB |
最終ジャッジ日時 | 2024-10-07 12:03:21 |
合計ジャッジ時間 | 3,644 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
import math MOD = 1000003 l = int(input()) cnt = {} for x in range(1, int(math.sqrt(l / 4)) + 1): for y in range(1, x): a, b = sorted([x ** 2 - y ** 2, 2 * x * y]) g = math.gcd(a, b) a //= g b //= g if not cnt.get((a, b), None) is None: continue c = int(math.sqrt(a * a + b * b)) if a + b + c > l // 4: continue if a * a + b * b == c * c: cnt[(a, b)] = 1 else: cnt[(a, b)] = 0 print(sum(list(cnt.values())) % MOD)