Stamps II

We want to send a postcard by mail. We need to stamp worth nn cents (n20n\ge 20). Stamps have values 7 and 4 cents. As space is limited we want to know the minimum number of stamps we need to put on the postcard, without losing a cent.

Using the definition

    struct Stamps {
        int stamp7;
        int stamp4;
    };

implement a recursive function

    Stamps min_stamps(int n)

computing the mimimum number of necessary worth 7 stamps (stamp7 field) and worth 4 stamps (stamp4 field) for a total worth of nn cents (n20)n \ge 20). For instance, for n=58n = 58, the result fields of min_stamps must be 6 and 4.

Observation

In order to complete the recursive case, note that recursive calls will always provide a Stamps tuple with stamp4 field at most 6.

Observation

This problem is an example about using tuples in order to define functions computing a result that does not have a default representation as a single value.

Observation

You only need to submit the required classes; your main program will be ignored.

Strictly obey the type definitions of the statement.

Problem information

Author: Jorge Castro

Generation: 2026-01-25T22:04:46.532Z

© Jutge.org, 2006–2026.
https://jutge.org