Computer Science/C++

백준 C++ | #1 BOJ5032 탄산음료 C++ 풀이

토마토. 2022. 7. 27. 14:41
#include <iostream>

int main() {
	int current, picked, need;
	std::cin >> current >> picked >> need;

	int soda = 0, tmp = (current+picked), tmp_soda = 0;

	while (tmp >= need) {
		tmp_soda = tmp / need;
		tmp -= tmp_soda * need;
		tmp += tmp_soda;
		soda += tmp_soda;
		tmp_soda = 0;
	}

	std::cout << soda << std::endl;
	return 0;
}