結果

問題 No.539 インクリメント
ユーザー nobigomunobigomu
提出日時 2018-07-09 00:53:58
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 08:24:33
合計ジャッジ時間 1,497 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 5 ms
4,376 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local ffi = require 'ffi'
for _=1,tonumber(io.stdin:read("*l")) do
	local s=io.stdin:read("*l")
	local t,j=ffi.new("int8_t[?]", #s+1, s),-1
	for i=#s-1,0,-1 do
		if t[i]>=48 and t[i]<=57 then
			t[i]=t[i]+1
			if t[i]<=57 then break else t[i]=48 end
			if i==0 or t[i-1]<48 or t[i-1]>57 then j=i break end
		end
	end
	if j<0 then
		print(ffi.string(t))
	else
		local t=ffi.string(t)
		print(t:sub(1,j).."1"..t:sub(j+1))
	end
end
0