#132267
๐ Question ?
https://school.programmers.co.kr/learn/courses/30/lessons/132267
class Solution {
fun solution(a: Int, b: Int, n: Int): Int {
var answer: Int = 0
return answer
}
}
๐งฉ Thought Process
- while๋ฌธ ์์์ ๋งค๋ฒ ๋๋์ด์ฃผ๊ณ ๋ชซ ๋ํด์ฃผ๊ธฐ
๐ Answer
class Solution {
fun solution(a: Int, b: Int, n: Int): Int {
var answer: Int = 0
var bottleNumber: Int = n
var remainder: Int = 0
while (bottleNumber>=a) {
answer += (bottleNumber/a)*b
remainder = (bottleNumber%a)
bottleNumber = (bottleNumber/a)*b + remainder
}
return answer
}
}
๐ Result
๐ Comment
๋๋์ ์ด๋ ๊ณฑ์ ์์ ์๋ชป ์ ์ด์ ์ค๋๊ฑธ๋ฆผ. ๋๋์ ํ๋ฉด ๋๋จธ์ง๋ฅผ ๋ฒ๋ฆฌ๊ธฐ ๋๋ฌธ์ ๋๋์ ์ ์ธ์ ํ๋์ ๋ฐ๋ผ ๊ฐ์ด ๋ฐ๋.