230815 콜라 문제

Jongleee·2023년 8월 15일
0

TIL

목록 보기
338/576
public int solution(int a, int b, int n) {
	int answer = 0;

	while (n >= a) {
		int temp = n / a;
		answer += temp * b;
		n = temp * b + (n % a);
	}

	return answer;
}

출처:https://school.programmers.co.kr/learn/courses/30/lessons/132267

0개의 댓글