結果

問題 No.1157 Many Quotients easy
ユーザー ciel
提出日時 2021-06-05 18:24:47
言語 Ruby
(4.0.6 + ACL)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 54 ms / 2,000 ms
+ 781µs
コード長 191 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10 ms
コンパイル使用メモリ 9,216 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2026-09-27 15:30:03
合計ジャッジ時間 2,979 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

class Integer
	def isqrt
		return 0 if self<=0
		return 1 if self<4 # 1
		x,y=0,self
		while x!=y&&x+1!=y
			x,y=y,(self/y+y)/2
		end
		x
	end
end
n=gets.to_i
s=n.isqrt
p 2*s-(n/s==s ? 1 : 0)
0