Canadian Computing Competition: 2008 Stage 1, Senior #2
The game "Pennies in the Ring" is often played by bored computer programmers who have gotten tired of playing solitaire. The objective is to see how many pennies can be put into a circle. The circle is drawn on a grid, with its center at the coordinate
Input
The input is a sequence of positive integer values, one per line, where each integer is the radius of a circle. You can assume the radius will be less than or equal to
Output
You are to output, each on its own line, the number of pennies needed for each circle. You do not need to output
Sample Input
2
3
4
0
Output for Sample Input
13
29
49
Comments
FYI, creating a square that fully encompasses the circle (like such):
and checking every point in that square to see whether it lands in the circle will probably TLE. (You have to check up to 2.5 billion points).
Can someone tell me what's wrong with my program
Try this case
The correct output should be
This comment is hidden due to too much negative feedback. Show it anyway.
Observe that there are 5 lattice points within the circle.
TLE for last two cases
This can be done in
time.