結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,068 KB
testcase_01 AC 43 ms
54,856 KB
testcase_02 AC 38 ms
53,968 KB
testcase_03 AC 42 ms
54,400 KB
testcase_04 AC 62 ms
71,060 KB
testcase_05 AC 64 ms
72,732 KB
testcase_06 AC 72 ms
76,792 KB
testcase_07 AC 143 ms
80,656 KB
testcase_08 AC 715 ms
99,540 KB
testcase_09 AC 727 ms
101,812 KB
testcase_10 AC 569 ms
93,840 KB
testcase_11 AC 324 ms
87,100 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