Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Algorithm] 콜라 문제 #95

Closed
hwangJi-dev opened this issue Jan 26, 2023 · 0 comments
Closed

[Algorithm] 콜라 문제 #95

hwangJi-dev opened this issue Jan 26, 2023 · 0 comments

Comments

@hwangJi-dev
Copy link
Owner

hwangJi-dev commented Jan 26, 2023

💬 문제

[코딩테스트 연습 - 콜라 문제](https://school.programmers.co.kr/learn/courses/30/lessons/132267)


💬 Idea

  • n에도 b를 곱해주어야한다는 것을 간과해서 오래 걸린 문제.. 문제 이해를 잘하자 !!!!!

💬 풀이

func solution(a:Int, b:Int, n:Int) -> Int {
    var n = n
    var result = 0
    
    while n >= a {
        result += (n / a) * b
        n = (n / a) * b + (n % a)
    }
    
    return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant