結果
問題 | No.539 インクリメント |
ユーザー | 👑 obakyan |
提出日時 | 2019-05-27 09:00:09 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 239 ms / 2,000 ms |
コード長 | 716 bytes |
コンパイル時間 | 482 ms |
コンパイル使用メモリ | 5,336 KB |
実行使用メモリ | 5,216 KB |
最終ジャッジ日時 | 2023-10-17 18:10:10 |
合計ジャッジ時間 | 1,716 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 6 ms
4,348 KB |
testcase_02 | AC | 239 ms
5,208 KB |
testcase_03 | AC | 239 ms
5,216 KB |
ソースコード
local n = io.read("*n", "*l") local str, sstr, pre, suf = "", "", "", "" for i = 1, n do pre, suf = "", "" str = io.read() sstr = str:match("%d+") if(sstr ~= nil and str ~= sstr) then pre, sstr, suf = string.match(str, "(.*[^%d])(%d+)(.-)$") end if sstr == nil then print(str) else local len = #sstr local nums = {} for j = 1, len do table.insert(nums, tonumber(sstr:sub(j, j))) end for j = len, 1, -1 do nums[j] = nums[j] + 1 if nums[j] <= 9 then break else if j ~= 1 then nums[j] = 0 end end end io.write(pre) for j = 1, len do io.write(nums[j]) end io.write(suf .. "\n") end end