結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,224 KB
testcase_01 AC 52 ms
65,280 KB
testcase_02 AC 38 ms
52,096 KB
testcase_03 AC 52 ms
64,384 KB
testcase_04 AC 87 ms
76,672 KB
testcase_05 AC 86 ms
76,672 KB
testcase_06 AC 101 ms
76,616 KB
testcase_07 AC 362 ms
80,896 KB
testcase_08 AC 2,484 ms
103,632 KB
testcase_09 AC 2,647 ms
105,548 KB
testcase_10 AC 1,910 ms
94,232 KB
testcase_11 AC 1,092 ms
87,004 KB
権限があれば一括ダウンロードができます

ソースコード

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