結果
問題 | No.539 インクリメント |
ユーザー |
![]() |
提出日時 | 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")) dolocal s=io.stdin:read("*l")local t,j=ffi.new("int8_t[?]", #s+1, s),-1for i=#s-1,0,-1 doif t[i]>=48 and t[i]<=57 thent[i]=t[i]+1if t[i]<=57 then break else t[i]=48 endif i==0 or t[i-1]<48 or t[i-1]>57 then j=i break endendendif j<0 thenprint(ffi.string(t))elselocal t=ffi.string(t)print(t:sub(1,j).."1"..t:sub(j+1))endend