結果
問題 | No.152 貯金箱の消失 |
ユーザー |
![]() |
提出日時 | 2015-12-11 18:04:58 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 1,326 ms / 5,000 ms |
コード長 | 584 bytes |
コンパイル時間 | 55 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 6,400 KB |
最終ジャッジ日時 | 2024-09-15 08:00:15 |
合計ジャッジ時間 | 5,370 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#!/usr/bin/python # -*- coding: utf-8 -*- #ピタゴラス数 (a, b, c) が原始的であるためには、3つのうち2つが互いに素であることが必要十分である。 def gcd(a,b): while b: a,b = b, a%b return a def lcm(a,b): return a*b / gcd(a, b) L = input() m = 2 n = 1 ans = 0 while True: if gcd(m, n) == 1 and (m-n)%2 == 1: length = 4 * (2*m**2 + 2*m*n) if length <= L: ans += 1 if length > 5 * L: break if m - n == 1: m += 1 n = 1 else: n += 1 print ans