結果
| 問題 |
No.39 桁の数字を入れ替え
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2019-05-01 09:35:53 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 420 bytes |
| コンパイル時間 | 109 ms |
| コンパイル使用メモリ | 6,688 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-31 12:10:54 |
| 合計ジャッジ時間 | 763 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 4 |
ソースコード
local orig = io.read("*n")
local t = {}
while(0 < orig) do
local a = orig % 10
table.insert(t, a)
orig = math.floor(orig / 10)
end
local maxdig = 1
for i = 2, #t do
if(t[maxdig] < t[i]) then maxdig = i end
end
local reppos = maxdig
for i = #t, maxdig, -1 do
if(t[i] < t[maxdig]) then reppos = i break end
end
t[reppos], t[maxdig] = t[maxdig], t[reppos]
for i = #t, 1, -1 do
io.write(t[i])
end
io.write("\n")