結果

問題 No.539 インクリメント
ユーザー cielciel
提出日時 2024-04-18 12:04:29
言語 Crystal
(1.11.2)
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 15,861 ms
コンパイル使用メモリ 343,160 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 12:04:54
合計ジャッジ時間 17,614 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 177 ms
6,816 KB
testcase_02 AC 306 ms
6,944 KB
testcase_03 AC 317 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

require "big"
gets.to_s.to_i.times{
	s=gets.to_s.chomp
	endidx=s.rindex(/\d/)
	(puts s;next) if !endidx
	endidx+=1
	beginidx=(s[0,endidx].rindex(/[^\d]/)||-1)+1
	q=s[beginidx...endidx]
	if q[0]=='0'
		q="%0*d" % [q.size,BigInt.new(q)+1]
	else
		q=(BigInt.new(q)+1).to_s
	end
	puts s[0,beginidx]+q+s[endidx..-1]
}
0