목차
문제 정보
https://codeforces.com/problemset/problem/313/A
난이도 : A
유형 : Math
문제 풀이
- 입력값이 양수)
- 입력값 자체가 정답
- 입력값이 음수)
- 자릿수가 1개라면 정답은 0
- 그 외인 경우 첫 번째 자리를 뺀 수 vs 두 번째 자리를 뺀 수 중 더 큰 값이 정답
코드
import java.io.BufferedReader
import java.io.InputStreamReader
fun solution() = with(BufferedReader(InputStreamReader(System.`in`))) {
var input = readLine().toInt()
if (input < 0) {
if (input >= -10) {
input = 0
} else {
input = (input / 10).coerceAtLeast(input / 100 * 10 + (input % 10))
}
}
println(input)
}
fun main() {
solution()
}
'Algorithm, Problem Solving > codeforces' 카테고리의 다른 글
[codeforces][Kotlin] 1475A - Odd Divisor (0) | 2023.03.29 |
---|---|
[codeforces][Kotlin] 703A - Mishka and Game (0) | 2023.03.28 |
[codeforces][Kotlin] 466A - Cheap Travel (0) | 2023.03.25 |
[codeforces][Kotlin] 189A - Cut Ribbon (0) | 2023.03.24 |
[Codeforces][Kotlin] 1796A - Typical Interview Problem (0) | 2023.03.22 |
댓글