Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- UnrealEngine5
- directx
- IFileDialog
- 프로그래머스
- Unreal Engine5
- C
- RVO
- C++
- 줄 세우기
- DeferredRendering
- Frustum
- baekjoon
- GeeksForGeeks
- 티스토리챌린지
- const
- Programmers
- 1563
- UE5
- 백준
- 팰린드롬 만들기
- DirectX11
- algorithm
- softeer
- 2294
- UnrealEngine4
- 언리얼엔진5
- NRVO
- 오블완
- winapi
- RootMotion
Archives
- Today
- Total
Game Develop
[Algorithm]Baekjoon 1174번 :: 줄어드는 수 본문
https://www.acmicpc.net/problem/1174
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <functional>
#include <sstream>
#include <memory.h>
#include <deque>
#include <set>
#include <unordered_set>
#include <thread>
#include <atomic>
using namespace std;
int n;
vector<long long> answer;
void DFS(string num)
{
answer.push_back(stoll(num));
int endNum = num.back() - '0';
for (int i = endNum - 1; i >= 0; --i)
{
num.push_back(i + '0');
DFS(num);
num.pop_back();
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 9; i >= 0; --i)
{
string temp = "";
DFS(temp += i + '0');
}
sort(answer.begin(), answer.end());
if (n >= 1024) cout << -1;
else cout << answer[n - 1];
}
|
cs |
어떤 규칙으로 해야 정확한 순번으로 저장할 수 있을까.. 고민 좀 했었는데, 그냥 어떤 방식이든 줄어드는 수를 구한다음에 오름차순정렬을 해주면 된다는 걸 깨달았다.
'Algorithm > Baekjoon' 카테고리의 다른 글
[Algorithm]Baekjoon 11562번 :: 백양로 브레이크 (0) | 2025.02.05 |
---|---|
[Algorithm]Baekjoon 16638번 :: 괄호 추가하기 2 (0) | 2025.02.03 |
[Algorithm]Baekjoon 10819번 :: 차이를 최대로 (0) | 2025.01.26 |
[Algorithm]Baekjoon 1507번 :: 궁금한 민호 (0) | 2025.01.25 |
[Algorithm]Baekjoon 6236번 :: 용돈 관리 (0) | 2025.01.25 |