CCC '22 J1 - Cupcake Party

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type
Canadian Computing Competition: 2022 Stage 1, Junior #1

A regular box of cupcakes holds 8 cupcakes, while a small box holds 3 cupcakes. There are 28 students in a class and a total of at least 28 cupcakes. Your job is to determine how many cupcakes will be left over if each student gets one cupcake.

Input Specification

The input consists of two lines.

  • The first line contains an integer R0, representing the number of regular boxes.
  • The second line contains an integer S0, representing the number of small boxes.

Output Specification

Output the number of cupcakes that are left over.

Sample Input 1

Copy
2
5

Output for Sample Input 1

Copy
3

Explanation of Output for Sample Input 1

The total number of cupcakes is 2×8+5×3 which equals 31. Since there are 28 students, there are 3 cupcakes left over.

Sample Input 2

Copy
2
4

Output for Sample Input 2

Copy
0

Explanation of Output for Sample Input 2

The total number of cupcakes is 2×8+4×3 which equals 28. Since there are 28 students, there are no cupcakes left over.


Comments


  • 2
    mirabelleai  commented 56 days ago

    this is the first problem i did


    • 0
      Raynfall  commented 34 days ago

      Nice job. I would recommend learning languages like C++ for competetive programming, since it's faster and supported by basically all coding competitions.


      • 1
        ksuks1  commented 33 days ago

        Keep in mind that using C++ for competitve programming without a template is kind of a pain. The CCC supports Python3, C++, Java and from my experience, Python can solve all problems (unless specified to use c++). I tried to write c++ code during the contest, and it becomes tedious because the syntax of the lang makes it hard to write algorithms from scratch. Then again, it comes down to personal preference. I can see why many people use c++ but in my experience, python gets the job done.