Problem 1732. GJam: 2013 Rd1a Bullseye Painting - Large Numbers
Google Code Jam 2013 Round 1a Bullseye challenge is to determine how many full rings can be painted given an initial radius and an amount of paint.
Given a radius r, central white zone, create black rings of width 1 cm separated by 1 cm given P ml of paint that covers pi sq-cm per ml of paint provided.
The test cases are a few from the 6000 in the Large number set. In contest mode the player has 8 minutes to submit a response after downloading the data set.
Input: [r, p] uint64, 1<=r<=1E18, 1<=P<=2E18. Always enough P for one ring
Output: Rings
Examples:
[1 9] 1; % Normal number examples to understand concept [1 10] 2; [3 40] 3;
[1 1000000000000000000] 707106780 for Bullseye Large Number Challenge [1 2000000000000000000] 999999999 [760961177192651897 1521922354385303795] 1
Google Code Jam:
The next competition starts in April 2014. See details from above link.
Solutions to the various past Challenges using Matlab can be found via GJam Solutions.
Large number solutions require more elegant methods to avoid time-outs.
Related Challenges:
Usage of regexp is verboten
Solution Stats
Problem Comments
-
2 Comments
Does r=uint64(308436464205151562) make sense? It seems like the argument to uint64 is a double precision number, so you have already lost the precision you are trying to gain by using uint64.
r=uint64(308436464205151562) outputs for uint64(r) 308436464205151562. However, r=308436464205151562 outputs for uint64(r) 308436464205151552. A very small loss in precision, but still a loss. The Challenge set has some numbers that use all the paint if full precision math was used. If residual paint was required as an output then full precision is needed. For solutions using p=p-2*r-1 the errors in r and p may cause issues.
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
-
Check to see if a Sudoku Puzzle is Solved
321 Solvers
-
Increment a number, given its digits
650 Solvers
-
Get the length of a given vector
10948 Solvers
-
Sum the elements in either diagonal of a square matrix
210 Solvers
-
Adding and Subtracting UINT variables
46 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!