結果
| 問題 | No.539 インクリメント | 
| コンテスト | |
| ユーザー |  nobigomu | 
| 提出日時 | 2018-07-09 00:53:58 | 
| 言語 | Lua (LuaJit 2.1.1734355927) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 8 ms / 2,000 ms | 
| コード長 | 428 bytes | 
| コンパイル時間 | 341 ms | 
| コンパイル使用メモリ | 5,376 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-08 00:43:25 | 
| 合計ジャッジ時間 | 1,832 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
ソースコード
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
            
            
            
        