14916번: 거스름돈

문제접근🤔


놓쳤던 부분😅


코드😁


2020 KB

0 ms

#include <iostream>
using namespace std;

int main(void)
{
	int n;
	int answer = 0;

	cin >> n;

	if (n == 1 || n == 3)
		answer = -1;
	else
	{
		answer += n / 5;
		n %= 5;
		if (n % 2 != 0)
		{
			n += 5;
			answer -= 1;
		}
		answer += n / 2;
	}
	cout << answer;
	return (0);
}