結果
問題 |
No.152 貯金箱の消失
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:17:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 97 ms / 5,000 ms |
コード長 | 1,072 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 82,892 KB |
実行使用メモリ | 70,412 KB |
最終ジャッジ日時 | 2025-06-12 14:17:56 |
合計ジャッジ時間 | 1,552 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
import sys import math def count_pseudo_primitives(s_max): count = 0 m = 2 while True: max_n = m - 1 for n in range(1, max_n + 1): if (m - n) % 2 == 0: continue if math.gcd(m, n) != 1: continue a = m**2 - n**2 b = 2 * m * n c = m**2 + n**2 sum_abc = a + b + c if sum_abc > s_max: continue if a > b: a, b = b, a count += 1 found = False m += 1 for n in range(1, m): a = m**2 - n**2 b = 2 * m * n c = m**2 + n**2 sum_abc = a + b + c if sum_abc <= s_max: found = True break if not found: break return count def main(): L = int(sys.stdin.readline()) s_max = L // 4 if s_max < 12: print(0) return result = count_pseudo_primitives(s_max) print(result % 1000003) if __name__ == '__main__': main()