Programming Olympiad 2018 : Round 1
Not to be used before 13 August 2018
1. This paper is for ALL participants.
2. All answers must be TYPED or PASTED on your Answer Sheet. Handwritten Answer Sheets will be
disqualified.
3. Each correct answer for questions 1 and 2 earns 8 marks while a correct answer for question 3 earns
9 marks.
4. You have 60 minutes to attempt as many questions as possible.
5. Programs should be readable, concise, and use appropriate variable names.
6. Indicate the question, your name, surname and the language and version used in a comment at the
start of every program, e.g. “Q3 Sam King, Python 2.7”
7. Save your program as Qn Name Surname, e.g. Q3 Sam King
8. You may assume that the user input will satisfy the problem specification and so you do not need to
validate the input.
9. Do not write code to produce only specific answers, as the external judges may use other test cases.
10. After the contest you may be given time to print out your Answer Sheet. Do not make any changes
during this time.
11. Make sure you save the programs you have created and the Answer Sheet in a place where your
teacher can find them.
12. DO NOT MODIFY ANY FILES AFTER THE END OF THE CONTEST AS THIS WILL LEAD TO
YOUR DISQUALIFICATION.
Question 1: Cellphone price in cents the subscription plan costs, as shown
in the examples given below.
A cellphone service provider has offered a new
subscription plan. The specific pricing for daytime, Examples:
evening and weekend usage is given below:
Input: 45 0 1 Output: 50c
Daytime Evening Weekends Input: 162 61 66 Output: 12530c
100 free minutes Input: 82 89 15 Output: 6980c
then 80c per 70c per minute 50c per minute
minute
In the first example given, 45 daytime minutes, 0
evening minutes and 1 weekend minute were
Your task is to write a program to determine how used. As the first 100 daytime minutes are free, no
much the new subscription plan will cost, given how cost is allocated for daytime minutes. As no evening
many minutes are used for daytime, evening and minutes were used, no cost is allocated for the
weekends. These are given as three non-negative evening, and as only 1 minute was used on the
integers in the order of daytime, evening, then weekend, the total cost comes to 50c.
weekend. Your program should output the total
Test your program with the following cases: Question 3: Perfect
1 a) 97 1 0 A classic problem in mathematics is to determine if
1 b) 38 72 94 a given positive integer is perfect. We call a positive
integer, , perfect if it is equal to the sum of its
1 c) 193 24 34
proper positive divisors, that is, the sum of its
1 d) 378 342 919 positive divisors excluding the number itself. (Note
that a proper divisor of is a positive integer less
than which evenly divides . For example, the
Question 2: Rövarspråket
proper divisors of 6 are 1, 2 and 3, and the proper
Mark’s friend Jenny speaks a language called divisors of 8 are 1, 2 and 4).
Rövarspråket. You must assist Mark by developing
Examples of perfect numbers include 6 and 28,
a program that will help him translate a given phrase
noting that the proper divisors of 6 are 1, 2 and 3
into Rövarspråket. The rules are simple. For each
and that 1 + 2 + 3 = 6. The proper divisors of 28 are
word, every consonant is doubled up and the
1, 2, 4, 7 and 14, and also that 1 + 2 + 4 + 7 + 14 =
vowel ‘o’ is inserted in-between. Vowels and spaces
28.
are left intact.
As the vast majority of numbers are not perfect, we
The input phrase is given simply as a lowercase
can furthermore divide non-perfect numbers into two
sentence. Output should be a lowercase sentence
sets. We denote a positive integer as abundant if
giving the Rövarspråket translation of the input.
the sum of its proper divisors is greater than ,
Your task is to write a program that will provide you otherwise we denote as deficient if the sum of its
with the correct output. proper divisors is less than .
Examples: Note that 9 is a deficient number, since the proper
divisors of 9 are 1 and 3, and 1 + 3 = 4 which is less
Input: ruler Output: roruloleror than 9. Also, 12 is an abundant number, since the
proper divisors of 12 are 1, 2, 3, 4 and 6, and 1 + 2
Input: stubborn Output: sostotubobboborornon
+ 3 + 4 + 6 = 16 which is greater than 12.
Input: caps lock Output: cocapopsos lolocockok
Your task is to write a program that, given a single
positive integer , will determine if it is perfect,
Test your program with the following cases: deficient, or abundant.
2 a) computer Examples:
2 b) excellence Input: 12 Output: Abundant
2 c) expanding possibilities Input: 9 Output: Deficient
2 d) what a tangled web we weave Input: 28 Output: Perfect
Test your program with the following cases:
3 a) 48
3 b) 110
3 c) 496
3 d) 945