結果

問題 No.152 貯金箱の消失
ユーザー qibqib
提出日時 2022-11-30 17:18:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 741 ms / 5,000 ms
コード長 485 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 102,228 KB
最終ジャッジ日時 2024-04-16 15:18:27
合計ジャッジ時間 3,875 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,224 KB
testcase_01 AC 45 ms
55,040 KB
testcase_02 AC 40 ms
52,096 KB
testcase_03 AC 44 ms
53,872 KB
testcase_04 AC 67 ms
71,296 KB
testcase_05 AC 65 ms
71,296 KB
testcase_06 AC 81 ms
76,544 KB
testcase_07 AC 149 ms
80,636 KB
testcase_08 AC 714 ms
100,048 KB
testcase_09 AC 741 ms
102,228 KB
testcase_10 AC 564 ms
94,020 KB
testcase_11 AC 333 ms
87,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0