結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
👑 |
提出日時 | 2019-05-01 09:39:43 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 389 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 6,948 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 12:11:22 |
合計ジャッジ時間 | 730 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
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 for j = #t, 1, -1 do local maxdig = 1 for i = 2, j do if(t[maxdig] < t[i]) then maxdig = i end end if(t[j] < t[maxdig]) then t[j], t[maxdig] = t[maxdig], t[j] break end end for i = #t, 1, -1 do io.write(t[i]) end io.write("\n")