結果
| 問題 | No.152 貯金箱の消失 |
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:21:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 79 ms / 5,000 ms |
| コード長 | 1,072 bytes |
| コンパイル時間 | 156 ms |
| コンパイル使用メモリ | 82,500 KB |
| 実行使用メモリ | 71,144 KB |
| 最終ジャッジ日時 | 2025-06-12 19:22:05 |
| 合計ジャッジ時間 | 1,442 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()
gew1fw