๐ ๋ฌธ์
๐ง ์์ด๋์ด
๐ก ๋ฏธ๋ฆฌ ๋๋ ๊ฐ์ ํฉ์ฐํ์ฌ ์ค๋ฒํ๋ก์ฐ ๋ฐฉ์ง
๐ Kotlin Code
import java.io.BufferedReader
import java.io.InputStreamReader
private fun getRemain(n: Long): Int {
var dividend = 1L
var cnt = 1
while (dividend % n != 0L) {
dividend = (dividend * 10) % n + (1 % n)
cnt++
}
return cnt
}
fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val stringBuilder = StringBuilder()
while (true) {
val line = br.readLine()
if (line == "" || line == null) break
val result = getRemain(line.toLong())
stringBuilder.append("$result\n")
}
br.close()
print(stringBuilder.toString())
}
'Algorithm > Algorithm (๋ฌธ์ ํ์ด)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] 7662 ์ด์ค ์ฐ์ ์์ ํ (0) | 2022.11.20 |
---|---|
[๋ฐฑ์ค] 17835 ๋ฉด์ ๋ณด๋ ์น๋ฒ์ด๋ค (0) | 2022.11.18 |
[๋ฐฑ์ค] 1629 ๊ณฑ์ (0) | 2022.11.12 |
[๋ฐฑ์ค] 2295 ์ธ ์์ ํฉ (1) | 2022.11.05 |
[๋ฐฑ์ค] 18870 ์ขํ ์์ถ (0) | 2022.11.01 |