結果

問題 No.152 貯金箱の消失
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-23 18:50:01
言語 Ruby
(3.3.0)
結果
AC  
実行時間 347 ms / 5,000 ms
コード長 536 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 11,564 KB
実行使用メモリ 15,312 KB
最終ジャッジ日時 2023-10-11 18:22:37
合計ジャッジ時間 2,733 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,156 KB
testcase_01 AC 83 ms
15,272 KB
testcase_02 AC 81 ms
15,160 KB
testcase_03 AC 82 ms
15,152 KB
testcase_04 AC 84 ms
15,188 KB
testcase_05 AC 84 ms
15,208 KB
testcase_06 AC 86 ms
15,296 KB
testcase_07 AC 120 ms
15,048 KB
testcase_08 AC 346 ms
15,312 KB
testcase_09 AC 347 ms
15,260 KB
testcase_10 AC 283 ms
15,116 KB
testcase_11 AC 193 ms
15,028 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def gcd(a, b)
    while true do
        r = a % b
        if r == 0
            return b
        end
        a = b
        b = r
    end
end
l = gets.to_i
m = 2
count = 0
while true do
    n = 1
    limc = 0
    while n < m do
        a = m * m - n * n
        b = 2 * m * n 
        c = m * m + n * n
		if (a + b + c) * 4 > l
			n += 1
			limc += 1
			next
		end
        if gcd(a, b) != 1
            n += 1
            next
        end
        count += 1
        n += 1
    end
	if m - 1 == limc
		break
	end
    m += 1
end
puts count
0