0% found this document useful (0 votes)
6 views

Programming-Competition-Test-1

Uploaded by

roinieva22
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Programming-Competition-Test-1

Uploaded by

roinieva22
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Problem 1: Maximum of Three

You are given three integers a, b, and c.


Task:
Determine the maximum of the three numbers
Constraints
• 1 ≤ a, b, c ≤ 100
• All input values are integers.
Input
The input is given from Standard Input in the following format:
a
b
c

Output
Print the maximum number

Sample Input 1
3
8
5

Sample Output 1
8

Sample Input 2
6
6
6

Sample Output 2
6
Explanation:When all three numbers are the same, the maximum is that number itself.
Problem 2: Trapezoids
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h,
respectively.
Task:
Find the area of this trapezoid.
Constraints
• 1≦a≦100
• 1≦b≦100

• 1≦h≦100
• All input values are integers.
• h is even.
Input
The input is given from Standard Input in the following format:
a
b
h

Output
Print the area of the given trapezoid. It is guaranteed that the area is an integer.
Sample Input 1
3
4
2

Sample Output 1
7
Explanation: When the lengths of the upper base, lower base, and height are 3, 4, and 2,
respectively, the area of the trapezoid is (3+4)×2/2=7.
Sample Input 2
4
4
4

Sample Output 2
16
Explanation: In this case, a parallelogram is given, which is also a trapezoid.
Problem 3: Age Group
Given a person's age a, determine their age group.
Age groups are defined as:
• Infant: 0-1
• Child: 2-12
• Teenager: 13-19
• Adult: 20-64
• Senior: 65 and above
Constraints
• 0≦age≦120
• All input values are integers.
• All input values are integers.
Input
The input is given from Standard Input in the following format:
a
Output
Print the age group corresponding to the input age.

Sample Input 1
5

Sample Output 1
Child

Sample Input 2
25

Sample Output 1
Adult
Problem 4: Counting Unique Paint Can Colors
Takashi, an artist, has purchased three paint cans in the past three days. The colors of these cans
are represented by integers between 1 and 100, inclusive, and are denoted as a, b, and c. It's
possible that Takashi may have bought multiple paint cans of the same color.
Task:
Write a program to count the number of unique colors among the three paint cans.

Constraints
1≦a,b,c≦100

Input
The input is given from Standard Input in the following format:
abc

Output
Print the number of different kinds of colors of the paint cans.

Sample Input 1
314

Sample Output 1
3
Explanation: Three different colors: 1, 3, and 4.

Sample Input 2
5 5 55

Sample Output 2
2
Explanation: Two different colors: 5 and 55.
Problem 5: Infinite Coins
Alex has 𝑨 1-peso coins and an unlimited supply of 20-peso coins. Determine if Alex can make an
exact payment of 𝑵 pesos using only these coins.
Constraints
• N is an integer between 1 and 10000 (inclusive).

• A is an integer between 0 and 1000 (inclusive).


Input
The input is given from Standard Input in the following format:
N
A
Output
If Alex can pay exactly N pesos using only his 1-peso and 20-peso coins, print Yes; otherwise,
print No.
Sample Input 1
21
1
Explanation: Alex can pay exactly 21 pesos by using 1 1-peso coin and 1 20-peso coin.
Sample Input 2:
30
0
Sample Output 2:
No
Explanation: Alex cannot pay exactly 30 pesos because he does not have any 1-peso coins to make
up the remaining amount after using 20-peso coins (the closest he can get is 20 pesos, which is
less than 30, or 40 pesos using 2 20-peso coins, which is more than 30).

You might also like