結果

問題 No.539 インクリメント
ユーザー cielciel
提出日時 2024-04-18 11:42:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,934 ms / 2,000 ms
コード長 268 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2024-04-18 11:42:57
合計ジャッジ時間 5,176 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
12,160 KB
testcase_01 AC 91 ms
23,680 KB
testcase_02 AC 1,934 ms
24,832 KB
testcase_03 AC 1,599 ms
24,320 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

puts gets.to_i.times.map{
	s=gets.chomp
	endidx=s.rindex(/\d/)
	next s 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,q.to_i+1]
	else
		q=(q.to_i+1).to_s
	end
	s[0,beginidx]+q+s[endidx..-1]
}
0