Sie sind auf Seite 1von 2

Problem 44 Dial the Letters

Bob was given the task of ordering from McDonalds for the overnight party. Bob asked Alice for the
delivery number, and Alice politely said 8MCDO. Bob thought Alice was so stupid for giving him letters
instead of numbers. Can you help Bob translate the letters for him?
--------------------| 1
| 2 | 3
|
|
| ABC | DEF |
--------------------| 4
| 5 | 6
|
| GHI | JKL | MNO |
--------------------| 7
| 8 | 9
|
| PQRS | TUV | WXYZ |
---------------------

Write a program that accepts a string of alphabetic letters, possibly with some
digits from 0 to 9. You are ensured that the input contains no whitespace and
that all letters are in uppercase. Output the same string but with the all the
letters replaced by the corresponding digits according to the keypad above. See
sample test cases. Hint: Use s = input('Enter string: ','s');

Input
Output
8MCDO
86236
000000O 0000006
SHAKEYS 7425397
UP000
87000

Problem 28 Yarks Burgers


Yarks Burgers is home to the beefiest, juiciest, greasiest burgers in town. Some burgers are small (Minor
League) and some are really, really big (Major League). But their burgers were not affordable. In fact,
there was a time they had to cut down the number of employees to save the business. They were broke,
until one of them had a solution that could change everythingpromo deals.
There are 3 promo deals: Buy 2 burgers for X pesos, Buy 3 burgers for Y pesos, and Buy 5 burgers
for Z pesos. The manager has the freedom to set X, Y, and Z depending on his mood. Only one kind of
burger is sold in any promo. However, Epi was a clever kid who could outsmart any deal. Armed with P
pesos in his wallet, he knew the most number of burgers he could buy out of any promo combination.
Given, X, Y, Z, and P, how many burgers can he buy?
Write a program that accepts 4 integers, X, Y, Z, and P, with their
meanings above. Output an integer denoting the maximum
number of promo burgers Epi can buy. It is possible that his money
cant buy any promo, in which case, the answer is 0. No promo is
less than PhP100.00 and P 104. See sample test cases.

X
100
400
400
100

Y
Z
P
Output
200 210 2200
52
500 1000 500
3
500 1000 1000
6
200 300
50
0

Problem 23 Polvoron Eating Contest


Justin entered a polvoron eating contest. A contestant must swallow as many polvoron ovals as he/she
can within a certain time limit! An unlimited supply of drinking water is also available.
Here is the catch: There are 2 kinds of polvoron ovals. The polvoron wrapped in red contains nuts, which
definitely takes longer to finish than the ones wrapped in yellow. Each red polvoron finished is worth R
points and each yellow polvoron finished is worth Y points. Justin can finish a red polvoron in 7 seconds
and a yellow polvoron in 5 seconds. No points will be given to unfinished polvorons. You can assume
that Justins drinking takes no time at all. Given a time limit, T, can you help him decide on a strategy?
Make a program that accepts 3 positive integers R, Y, and T, with their meanings
described above. T is given in minutes and T 60. R and Y values will not exceed 100.
Output a single integer, M, denoting the maximum points Justin can get. See sample
test cases. Hint: A careful brute force solution always works.

Problem 69 Bacon Pancake Delivery


Bacon pancake is the newest breakfast meal available at Jakes
Diner. At a certain Jakes Diner branch, Finn was dubbed the fastest
delivery guy. He can deliver any meal to any destination in 30
minutes or less! This time, the manager tested his skills by making
him deliver three fresh batches of bacon pancakes to three
different destinations, in just one trip!

R
3
5
4

Y T
M
2 1 25
3 1 41
3 10 360

Sample Input / Output


A B C D E F Output
-2 1 0 -2 1 3 12.3734
1 2 3 4 5 6 15.7032
-2 2 1 -1 3 1 12.1701
1 1 -1 -1 -1 1 6.8284

The Diner is located at (0, 0) in the local map. Because there are three
destinations, located at (A, B), (C, D), and (E, F), Finn has the freedom to
choose the order of his visits. In one whole trip, he starts from the Diner,
and then visits the three destinations one by one in any order, and finally
returns to the Diner. Given A, B, C, D, E, and F, in km, can you help Finn
determine the minimum travel distance of one whole trip?
Make a program that accepts 6 integers, A, B, C, D, E and F, whose absolute values are less than 100.
Output the minimum travel distance (in km) of one whole trip, accurate to 4 decimal places. You are
ensured that no 2 destinations are the same, and no destination is at (0, 0). To illustrate the answer for
the first sample test case, the figure above can help you. See other sample test cases.

Das könnte Ihnen auch gefallen