Canadian Coding Competition(CCC) 2022 Junior 题解

Problem J1: Cupcake Party

Problem Description

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 R ≥ 0, representing the number of regular boxes.

• The second line contains an integer S ≥ 0, representing the number of small boxes.

Output Specification

Output the number of cupcakes that are left over.

Sample Input 1

2

5

Output for Sample Input 1

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.

Problem J2: Fergusonball Ratings

Problem Description

Fergusonball players are given a star rating based on the number of points that they score and the number of fouls that they commit. Specifically, they are awarded 5 stars for each point scored, and 3 stars are taken away for each foul committed. For every player, the number of points that they score is greater than the number of fouls that they commit. Your job is to determine how many players on a team have a star rating greater than 40. You also need to determine if the team is considered a gold team which means that all the players have a star rating greater than 40.

Input Specification

The first line of input consists of a positive integer N representing the total number of players on the team. This is followed by a pair of consecutive lines for each player. The first line in a pair is the number of points that the player scored. The second line in a pair is the number of fouls that the player committed. Both the number of points and the number of fouls, are non-negative integers.

Output Specification

Output the number of players that have a star rating greater than 40, immediately followed by a plus sign if the team is considered a gold team.

Problem J3: Harp Tuning

Problem Description

The CCC harp is a stringed instrument with strings labelled A, B, . . . , T. Like other instruments, it can be out of tune. A musically inclined computer science student has written a clever computer program to help tune the harp. The program analyzes the sounds produced by the harp and provides instructions to fix each string that is out of tune. Each instruction includes a group of strings, whether they should be tightened or loosened, and by how many turns. Unfortunately, the output of the program is not very user friendly. It outputs all the tuning instructions on a single line. For example, the single line AFB+8HC-4 actually contains two tuning instructions: AFB+8 and HC-4. The first instruction indicates that harp strings A, F, and B should be tightened 8 turns, and the second instruction indicates that harp strings H and C should be loosened 4 turns. Your job is to take a single line of tuning instructions and make them easier to read.

Input Specification

There will be one line of input which is a sequence of tuning instructions. Each tuning instruction will be a sequence of uppercase letters, followed by a plus sign (+) or minus sign (-), followed by a positive integer. There will be at least one instruction and at least one letter per instruction. Also, each uppercase letter will appear at most once. The following table shows how the available 15 marks are distributed.

 Problem J4/S2: Good Groups

Problem Description

A class has been divided into groups of three. This division into groups might violate two types of constraints: some students must work together in the same group, and some students must work in separate groups. Your job is to determine how many of the constraints are violated.

Input Specification

The first line will contain an integer X with X ≥ 0. The next X lines will each consist of two different names, separated by a single space. These two students must be in the same group. The next line will contain an integer Y with Y ≥ 0. The next Y lines will each consist of two different names, separated by a single space. These two students must not be in the same group. Among these X + Y lines representing constraints, each possible pair of students appears at most once. The next line will contain an integer G with G ≥ 1. The last G lines will each consist of three different names, separated by single spaces. These three students have been placed in the same group. Each name will consist of between 1 and 10 uppercase letters. No two students will have the same name and each name appearing in a constraint will appear in exactly one of the G groups. The following table shows how the available 15 marks are distributed at the Junior level.

Output Specification

Output an integer between 0 and X +Y which is the number of constraints that are violated.

Problem J5: Square Pool

Problem Description

Ron wants to build a square pool in his square N-by-N yard, but his yard contains T trees. Your job is to determine the side length of the largest square pool he can build. Input Specification The first line of input will be an integer N with N ≥ 2. The second line will be the positive integer T where T < N2 . The remaining input will be T lines, each representing the location of a single tree. The location is given by two positive integers, R and then C, separated by a single space. Each tree is located at row R and column C where rows are numbered from top to bottom from 1 to N and columns are numbered from left to right from 1 to N. No two trees are at the same location. The following table shows how the available 15 marks are distributed.

猜你喜欢

转载自blog.csdn.net/GeekAlice/article/details/128520614
ccc
今日推荐