結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-27 09:00:09 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 240 ms / 2,000 ms |
| コード長 | 716 bytes |
| コンパイル時間 | 106 ms |
| コンパイル使用メモリ | 6,812 KB |
| 実行使用メモリ | 6,940 KB |
| 最終ジャッジ日時 | 2024-09-17 15:27:30 |
| 合計ジャッジ時間 | 1,420 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
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