Time limit: 1 second
A common problem in mathematics is to determine which quadrant a given point lies in. There are four quadrants, numbered from 1 to 4, as shown in the diagram below:
For example, the point A, which is at coordinates (12, 5) lies in
quadrant 1 since both its
Your job is to take a point and determine the quadrant it is in. You
can assume that neither of the two coordinates will be
The first line of input contains the integer
Output the quadrant number (
12
5
1
9
-13
4
Time limit: 1 second
Suppose we have a number like 12. Let’s define shifting a number to mean adding a zero at the end. For example, if we shift that number once, we get the number 120. If we shift the number again we get the number 1200. We can shift the number as many times as we want.
In this problem you will be calculating a shifty
sum, which is the sum of a number and the numbers we get by
shifting. Specifically, you will be given the starting number
For example, the shifty sum when
The first line of input contains the number
Output the integer which is the shifty sum of
12
3
13332
Time limit: 1 second
You live in Grid City, which is composed of integer-numbered streets
which run east-west (parallel to the
You drive a special electric car which uses up one unit of electrical charge moving between adjacent intersections: that is, moving either north or south to the next street, or moving east or west to the next avenue). Until your battery runs out, at each intersection, your car can turn left, turn right, go straight through, or make a U-turn. You may visit the same intersection multiple times on the same trip.
Suppose you know your starting intersection, your destination intersection and the number of units of electrical charge in your battery. Determine whether you can travel from the starting intersection to the destination intersection using the charge available to you in such a way that your battery is empty when you reach your destination.
The input consists of three lines. The first line contains
The second line contains
The third line contains an integer
For 3 of the 15 available marks,
For an additional 3 of the 15 marks available,
Output Y
if it is possible to move from the
starting coordinate to the destination coordinate using exactly N
.
3 4
3 3
3
Y
One possibility is to travel from
10 2
10 4
5
N
It is possible to get from
It is also possible to travel using 4 units of electricity as in the
following sequence:
Time limit: 1 second
Wendy has an LED clock radio, which is a 12-hour clock, displaying
times from 12:00
to
11:59
. The hours do not have leading zeros but
minutes may have leading zeros, such as 2:07
or 11:03
.
When looking at her LED clock radio, Wendy likes to spot arithmetic
sequences in the digits. For example, the times
12:34
and 2:46
are
some of her favourite times, since the digits form an arithmetic
sequence.
A sequence of digits is an arithmetic sequence if each digit after the first digit is obtained by adding a constant common difference. For example, 1,2,3,4 is an arithmetic sequence with a common difference of 1, and 2,4,6 is an arithmetic sequence with a common difference of 2.
Suppose that we start looking at the clock at noon (that is, when it
reads 12:00
) and watch the clock for some
number of minutes. How many instances are there such that the time
displayed on the clock has the property that the digits form an
arithmetic sequence?
The input contains one integer
For 4 of the 15 available marks,
Output the number of times that the clock displays a time where the
digits form an arithmetic sequence starting from noon
(12:00
) and ending after
34
1
Between 12:00
and
12:34
, there is only the time
12:34
for which the digits form an arithmetic
sequence.
180
11
Between 12:00
and
3:00
, the following times form arithmetic
sequences in their digits (with the difference shown:
12:34
(difference 1),
1:11
(difference 0),
1:23
(difference 1),
1:35
(difference 2),
1:47
(difference 3),
1:59
(difference 4),
2:10
(difference -1),
2:22
(difference 0),
2:34
(difference 1),
2:46
(difference 2),
2:58
(difference 3).
Time limit: 2 seconds
Tudor is a contestant in the Canadian Carpentry Challenge (CCC). To
win the CCC, Tudor must demonstrate his skill at nailing wood together
to make the longest fence possible using boards. To accomplish this
goal, he has
A board is made up of exactly
two pieces of wood. The length of a board made of wood with
lengths
The first line will contain the integer
The second line will contain
For 7 of the 15 available marks,
For an additional 6 of the 15 available marks,
For an additional 1 of the 15 available marks,
Output two integers on a single line separated by a single space: the length of the longest fence and the number of different heights a longest fence could have.
4
1 2 3 4
2 1
Tudor first combines the pieces of wood with lengths
5
1 10 100 1000 2000
1 10
Tudor can’t make a fence longer than length