Dev/BAEKJOON 백준
[백준/BOJ] 백준 코딩 알고리즘 1748번/C++
솔버(Solver)
2019. 7. 7. 20:26
728x90
반응형
백준 코딩 알고리즘 문제 1748번
백준 코딩 알고리즘 문제 1748번 풀이 - 사용 언어: C++
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
|
#include <iostream>
using namespace std;
int main() {
int inputNum = 0;
int totalLength = 0;
cin >> inputNum;
int length = 1, risingSpot = 1;
for (int i = 1; i <= inputNum; i++) {
//자리수가 증가하는 경계를 만날 때 까지, 유지되는 같은 자리수를 더한다
if (i == risingSpot*10) {
risingSpot *= 10;
length++;
}
totalLength += length;
}
cout << totalLength << endl;
return 0;
}
|
cs |
728x90
반응형