https://www.acmicpc.net/problem/2839


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream>
using namespace std;
 
int main() {
    int input;
    int a = , b = 0;
 
    cin >> input;
 
    if (input == || input == 7) {
        cout << -1;
        return 0;
    }
 
    while (input > 0) {
 
        if (input % == 0) {
            a = input / 5;
            break;
        }
 
        else {
            input = input - 3;
            b++;
        }
    }
    cout << a + b << endl;
}
cs

Problem

Mirko works in a sugar factory as a delivery boy. He has just received an order: he has to deliver exactly N kilograms of sugar 

to a candy store on the Adriatic coast. Mirko can use two types of packages, the ones that contain 3 kilograms, and the ones 

with 5 kilograms of sugar.

Mirko would like to take as few packages as possible. For example, if he has to deliver 18 kilograms of sugar, 

he could use six 3-kilogram packages. But, it would be better to use three 5-kilogram packages, and one 3-kilogram package,

 resulting in the total of four packages.

Help Mirko by finding the minimum number of packages required to transport exactly N kilograms of sugar.

Input

The first and only line of input contains one integer N (3 ≤ N ≤ 5000).

Output

The first and only line of output should contain the minimum number of packages Mirko has to use. If it is impossible 

to deliver exactly N kilograms, output -1.




+ Recent posts