Algorithm
Kotlin ์ฝํ๋ฆฐ ๋ฐฑ์ค 2659 ์ญ์์นด๋ ๋ฌธ์
๋
ธ๋ฃจ๋ฃฝ
2022. 12. 16. 16:57
https://www.acmicpc.net/problem/2659
๋ค ์๋ฆฌ ์๋ก ๋ง๋ค ์ ์๋ ๊ฐ์ฅ ์์ ์์ธ ์๊ณ์๋ฅผ ๊ตฌํด์,
๋ชจ๋ ์๊ณ์๋ค ์ค์์ ๋ช ๋ฒ์งธ๋ก ์์ ์๊ณ์์ธ์ง ์นด์ดํธํด์ฃผ๋ฉด ๋๋ค!
import java.lang.Integer.min
/**
* ์ญ์์นด๋ ๋ฌธ์
* https://www.acmicpc.net/problem/2659
*/
private var card = 0
private var answer = 0
private fun getClockNum(num: Int): Int {
var temp = num
var result = num
repeat(4) {
temp = temp % 1000 * 10 + temp / 1000
result = min(result, temp)
}
return result
}
private fun solution() {
for (i in 1111..getClockNum(card)) {
if (getClockNum(i) == i) answer++
}
println(answer)
}
private fun input() = with(System.`in`.bufferedReader()) {
card = readLine().replace(" ", "").toInt()
close()
}
fun main() {
input()
solution()
}