You are on page 1of 7

1) Turtle, Turtle

For thousands of years, turtles have been known to migrate in unusual patterns. These patterns can be attributed
to the turtles’ extreme self-consciousness about the way in which they walk in a single direction only during a
given day. Scientists have observed that the turtles’ migration, lasting X days, consists of day-long excursions
in exclusively one compass direction. As the turtle emerges from his shell the next day, he chooses a new
arbitrary compass direction in which to walk.

Scientists have determined that the turtles only move in one of eight directions:
N, NW, NE, W, E, S, SW, or SE. (North, Northwest, Northeast, West, East, South, Southwest, Southeast).

The scientists want to figure out how successful the migration is based on how far they manage to get from their
starting location. They are studying one turtle in particular, Geoffrey. Given the number of days of migration,
and a compass direction and distance (in the unit of Eastern-Pacific mule paces) for each day, what is the total
migratory displacement (in Eastern-Pacific mule paces, within 10e-9 paces) from Geoffrey’s original starting
point?

Input:
The first line of input will contain the number of days, D. (0<=D<=500)
The following D lines will contain a string representing a direction, followed by a space followed by the
number of paces, P. (0<=P<=500). All directions will be valid and uppercase.

Output:
Output only the answer, on its own line. The answer must be within 10e-9.

Input Output Info


1 5 He only moved once, the direction
SW 5 didn’t matter.
2 5 After the second day he is at
NW 3 4.949747468 paces West and
SW 4 0.707106781 paces South of his
starting point.
4 7.43056
NE 1
SW 3
W5
SW 1
7 7.01015
NW 3
N2
NE 1
W1
W3
S2
W1
2) Pixel Sizes

A 1080p display contains 1920x1080 pixels in a ratio of 16:9. In general, a TV is described in inches referring
to the diagonal of the screen. So, if the height of the screen is 9 inches and the width is 16 inches, the TV is
described as sqrt(337) inches (roughly 18.36 inches). Assuming that the area of the screen is completely
comprised of pixels and nothing else, we can determine the area of a pixel if we have the diagonal.

If the diagonal is sqrt(337) inches, then we know that the width and height are 16 and 9 inches, respectively.
This means the area is 144 sq inches. Therefore a pixel requires 6.94444e-05 square inches.

You will be given the square of the diagonal. Output the area of a pixel.

Input:
The first line of input will contain the square of the diagonal, D. (10<=D<=10000)

Output:
Output only the answer, on its own line. The answer must be within 10e-9.

Input Output Info


337 6.94444e-05 This is from the write-up and
reflects a 16x9 inch TV.
1024 0.000210775 This is a 32” TV.
8368 0.00172418
7660 0.00157823
3) A Paper Scam

Jason is trying to sell his inventory of paper. He has two kinds of paper in stock: small paper (sp), and green
paper (gp). Jason’s customers are very cautious about giving out their names, so they use crazy pseudonyms to
order the paper. He has an order sheet of customer names, quantities, and paper types.

Green paper costs 10 times as much as small paper and Jason only records his own costs in terms of gp. For
example, an order of 5 small paper would be recorded as 0.5 gp.

Given the order sheet, determine the cost, in terms of gp, to fulfill all of the orders.

Input:
The first line of input will contain the number of orders, N. (0<=N<=500)
Each of the following N lines are as follows:
<name> <quantity> <paper type (sp or gp)> Each field is separated by a single blank space.

The customer names can be any length, with each part of their name separated by a single blank space, such as
“Jason Loew” or “MC Hammer III”.

Quantities range from [0,5000].

Output:
The total cost, in terms of gp (just the number) to fulfill the order.

Input Output Info


2 7
Walter Bartholomew Billingsworth 20 sp
Two Handed Turkey Sandwich 5 gp
4 7.5 Repeat customers are
Walter Bartholomew Billingsworth 20 sp allowed.
Two Handed Turkey Sandwich 5 gp
Walter Bartholomew Billingsworth 1 sp
Walter Bartholomew Billingsworth 4 sp
2 2.8 Yes, crazy pseudonyms.
Asdhdf sdfhjks rsrs sdr drjhfkjghf gp gp sp 2 gp
Gfgdspsppspspgpgppg spgpsp gpsgpsd 8 sp
4) Sequences

A sequence can be defined in many different ways, we’ll look at one way here:

X0 = A
X1 = B
X2 = (C*X0 + D*X1)%E
XN = (C*XN-2 + D*XN-1)%E

Given A, B, C, D and E. Your job is to find XF.

Input:
The first line will contain the integers, A, B, C, D, E and F in order with a single space between them.
(0<=A,B,C,D<=1000), (2<=E<=20,000,000), (0<=F<=250,000,000)

Output:
Only output the answer on a single line.

Input Output Info


1 1 1 1 10000000 0 1 Fibonacci, first element
1 1 1 1 10000000 1 1 Fibonacci, second element
1 1 1 1 10000000 2 2 Fibonacci, third element
1 1 1 1 10000000 3 3 Fibonacci, fourth element
1 1 1 1 10000000 4 5 Fibonacci, fifth element
1 1 1 1 10000000 5 8 Fibonacci, sixth element
1 1 1 1 10000000 6 13 Fibonacci, seventh element
1 1 1 1 10000000 12 233 Fibonacci, eighth element
999 999 1000 1000 1999999 4 499
645 261 410 899 369525 191826 159924
725 147 306 300 322639 178234 266132
596 218 202 329 106091 73071 9722
5) The Best Seat

When sitting in class, it is obvious that some students simply ruin the experience for everyone. Some are
distracting, some smell funny, some are simply annoying. Over the years you have been able to come up with a
quality rating for students that ranges from (0.0,1.0] with 1.0 being the best. However, this rating isn’t enough
alone. Distance from a seat to a student determines how powerful of an effect they have at damaging the value
of a seat. A seat’s value, lower is better, is the sum of all student influences.

Influence of a student = (1.0/(student quality)) * (max distance two seats can be apart) / (distance between the
student and a seat)

The classroom can be considered a grid of X rows and Y columns where the distance between two adjacent
seats is 1. In a classroom with 4 rows and 5 columns, the maximum distance is the distance from seat[0][0] to
seat[3][4] which is 5.

When you get to class you must find the best empty seat (where lowest seat value determines the best seat).
Output the value of the Beat Seat.

Input
The first line contains X and Y (rows and columns). (1<=X,Y<=100)
On the following X lines there are Y values. These values are:
“E” Empty Seat (There is guaranteed to be at least 1 in any input set)
“X” No seat (You can’t sit here but no one else can either)
<float> Quality value ranging from (0.001 -> 1.000 in increments of 0.001)

Output
Output only the value of the Best Seat on its own line. The answer must be within 10e-9.

Input Output Info


23 0 No students in class, this is good!
EEE
EEE
11 10 333.644
0.071 X X 0.241 X X 0.459 0.195 0.978 X
0.997 X X E 0.576 X X 0.484 X 0.562
E E X X E 0.741 E 0.947 E E
0.623 E 0.634 E 0.139 E E X 0.941 0.157
E X X E 0.318 0.211 0.724 E X X
XEEEEXEEXX
E X X E E E E 0.327 0.444 E
X 0.503 X E 0.64 E E 0.243 0.175 E
X 0.048 0.347 0.566 0.403 E 0.68 0.345 0.914 X
X 0.551 E 0.14 0.797 E 0.139 X E X
X E E E 0.641 0.109 0.96 X 0.965 E
23 5.81721 There is only one empty seat, so what is the
E 1.0 X value?
X 1.0 0.5
23 5.81721 The two empty seats are equivalent.
E 1.0 X
E 1.0 0.5
23 9.0274 The upper-left is better. The value of the
E 1.0 E upper-right seat is 11.4995.
X 0.33 0.5
6) Dorkmids

In the land of Dorkmor, the currency is the Dorkmid. The Dorkmid is a great currency since a Dorkmid can be
broken into two equal halves each representing half of the prior value. Therefore, from 1 Dorkmid any value in
the form of 1/2X can be obtained. Eventually Dorkmids get too small to be practical, so, practical use rarely
breaks them up more than 80 times.

The Royal Bank of Dorkmoria has a problem. They have Dorkmids to loan out at various interest rates and
monthly payments schedules but they do not know how to determine the payments required to pay off the loan
in the time they permit.

Given an interest rate (yearly rate, there are 12 monthly periods of equal length and interest is compounded), a
starting balance and a number of months, determine the monthly payment that allows the balance to be paid off
in the specified time period. Payments are made at the end of the month. So, interest is added based on the
starting balance.

Input:
The input consists of a single line with 3 values separated by a single space
The first value is the interest rate, I. (0.00<=I<=100, in increments of 0.01)
The second value is the starting balance, B. (0<=B<=2000000)
The third value is the number of moths, M. (1<=M<=720)

Output:
Output the monthly payment on a single line. The answer must be within 10e-9. It must also use less than 80
bits of precision.

Input Output Info


0.10 5000 4 1276.15 First month:
Interest: 41.6667
End Balance: 3765.52
Second month:
Interest: 31.3793
End Balance: 2520.75
Third month:
Interest: 21.0062
End Balance: 1265.6
Fourth month:
Interest: 10.5467
End Balance: 4.54747e-13
0.55 1787598 59 88200.4
0.59 1520031 631 74734.9
7) The Archer

Eddie the Awesome was recently injured in a violent chess accident and was forced to compete in the annual
archery tournament with a strained muscle in his back. The contest required competitors to shoot an apple that
sits on the head of a mannequin that happens to be at the same height as Eddie the Awesome’s arrow. Once
Eddie the Awesome got ready to shoot, his back acted up and he became unable to readjust the angle at which
he was aiming.

Eddie the Awesome knows that he can still hit the target if he applies the right amount of force to launch the
arrow. This is since he only cares about the horizontal distance that the arrow travels.

Given the horizontal distance to the target and the angle the arrow is pointed above the horizon, determine the
force necessary to project the arrow onto the target. Use 9.8m/s as the effect of gravity on the arrow.

Input:
The input consists of two values on a single line separated by a single space.
The first value is the angle, A. A ranges from [1,89] degrees. However, it is given in radians.
The second value is the horizontal distance in meters (floating point), D. (0<=D<=250000)

Output:
The output should be the initial velocity of the arrow as Eddie the Awesome shoots it on a single line. The
answer must be within 10e-9.

Input Output Info


0.5235987756 40 21.2754 This is 30 degrees. Horizontal component is 18.425 and it is
airborne for 2.170959184 seconds
0.5235987756 60 26.0569 This is 30 degrees
0.2617993878 40 28 This is 15 degrees. Horizontal component is 27.0459 and it
is airborne for 1.478965306 seconds
0.2617993878 60 37.0405 This is 15 degrees
1.16937059884 1688.15 151.653
0.15707963268 1650.73 228.802

You might also like