algorithm/BOJ
BOJ 1681번 줄 세우기
_JunHo
2020. 2. 10. 12:08
BOJ : https://www.acmicpc.net/problem/1681
github : https://github.com/junho0956/Algorithm/blob/master/1681/1681/%EC%86%8C%EC%8A%A4.cpp
마구잡이식으로 각 숫자마다 %10을 통해서 라벨 유무를 확인하는 식으로 구현하였는데
처음에는 TLE가 될 줄 알았지만 다행히? 성공하였습니다.
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
|
#include <iostream>
using namespace std;
typedef long long ll;
ll arr[1000001];
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, m;
cin >> n >> m;
int val = 1;
for (int i = 1; i <= n; i++) {
int num = val;
bool check = true;
while (num) {
if (num % 10 == m) { check = false; break; }
num /= 10;
}
if (check) arr[i] = val++;
else i--, val++;
}
cout << arr[n];
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|