문제접근![](data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)
•
최소로 거슬러줘야 하기 때문에 숫자가 큰 단위부터 나눠봄
•
나눈 후 2단위로 나뉘지 않으면 5를 더해서 다시 나눠봄
놓쳤던 부분![](data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)
코드![](data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)
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);
}
C++
복사