문제 출처 : https://www.acmicpc.net/problem/13297
언어 : Kotlin
문제 설명 :
Let’s face it... you are not that handy. When you need to make a major home repair, you often need to hire someone to help. When they come for the first visit, they make an estimate of the cost. Here they must be careful: if they overestimate the cost, it might scare you off, but if they underestimate, the work might not be worth their time.
Because the worker is so careful, it can take a long time for them to produce the estimate. But that’s frustrating — when you ask for an estimate, you really are asking for the magnitude of the cost. Will this be $10 or $100 or $1 000? That’s all you really want to know on a first visit.
Please help the worker make the type of estimate you desire. Write a program that, given the worker’s estimate, reports just the magnitude of the cost — the number of digits needed to represent the estimate.
입력 :
Input begins with a line containing an integer N (1 ≤ N ≤ 100). The next N lines each contain one estimated cost, which is an integer between 0 and 10100. (Some of the workmen overcharge quite a bit.)
출력 :
For each estimated cost, output the number of digits required to represent it.
제한 사항 :
- 시간 제한 : 2초
- 메모리 제한 : 512MB
입출력 예 :
입력 | 출력 |
5 314 1 5926 5 35897 |
3 1 4 1 5 |
3 0 10 100 |
1 2 3 |
풀이 :
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
fun main() = with(BufferedReader(InputStreamReader(System.`in`))) {
val bw = BufferedWriter(OutputStreamWriter(System.out))
repeat(readLine().toInt()) {
bw.write("${readLine().length}\n")
}
bw.flush()
bw.close()
}
'백준 > 문제' 카테고리의 다른 글
10931번: SHA-384 (0) | 2024.08.02 |
---|---|
13506번: 카멜레온 부분 문자열 (0) | 2024.08.01 |
27497번: 알파벳 블록 (0) | 2024.07.31 |
25178번: 두라무리 휴지 (0) | 2024.07.31 |
27962번: 오렌지먹은지오렌지 (0) | 2024.07.30 |
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!