๐ŸŽฒ ๋ฐฑ์ค€ 1038๋ฒˆ ๊ฐ์†Œํ•˜๋Š” ์ˆ˜

Jeongeunยท2024๋…„ 3์›” 3์ผ
0

๋ฐฑ์ค€

๋ชฉ๋ก ๋ณด๊ธฐ
177/186

๐Ÿ“ฃ ๋ฌธ์ œ

๐ŸŽจ ์ฐธ๊ณ  ์ฝ”๋“œ

์ฝ”๋“œ

const fs = require('fs'); 
const input = +fs.readFileSync('/dev/stdin').toString().trim().split(' ');

const decrease = [];

const getDec = (now, last) => {
  for (let i = last - 1; i >= 0; i--) {
    decrease.push(now * 10 + i);
    getDec(now * 10 + i, i);
  }
};

for (let i = 0; i <= 9; i++) {
  decrease.push(i);
  getDec(i, i);
}

decrease.sort((a, b) => a - b);

if (input >= decrease.length) console.log(-1);
else console.log(decrease[input]);

0๊ฐœ์˜ ๋Œ“๊ธ€