結果

問題 No.152 貯金箱の消失
ユーザー qib
提出日時 2022-11-30 17:10:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,193 ms / 5,000 ms
コード長 501 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 105,292 KB
最終ジャッジ日時 2024-10-07 11:53:38
合計ジャッジ時間 8,875 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

MOD = 1000003

l = int(input())
cnt = {}
for x in range(1, int(math.sqrt(l)) + 1):
  for y in range(1, x):
    a, b, _ = sorted([x ** 2 - y ** 2, 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)
0