### 2008 Canadian Computing Competition, Stage 1

## Problem S2: Pennies in the Ring

The game "Pennies in the Ring" is often played by bored computer programmers who have gotten tired of playing solitare. 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 (0, 0): A single penny is placed on every integer grid coordinate (e.g., (1, 1), (1, 2), etc.) that lies within or on the circle. It's not a very exciting game, but it's very good for wasting time. Your goal is to calculate how many pennies are needed for a circle with a given radius.### 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 25000. The last integer will be indicated by 0. You may assume that the grid is large enough for two pennies to be on adjacent integer coordinates and not touch.### Output

You are to output, each on its own line, the number of pennies needed for each circle. You do not need to output 0 for the last 0. You may assume that the number of possible pennies is less than 2 billion (which is only $20 million dollars: computer scientists have lots of money).### Sample Input

2 3 4 0

### Sample Output

13 29 49

All Submissions

Best Solutions

**Point Value:** 5

**Time Limit:** 5.00s

**Memory Limit:** 16M

**Added:** Sep 28, 2008

**Problem Types:**[Show]

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

XZNZon Dec 04, 2011 - 12:19:50 am UTC penny's radiusso the radius should less than 0.5 units right?

SourSpinachon Dec 04, 2011 - 2:14:18 am UTC Re: penny's radiusBut this shouldn't affect the code in any way, pennies are placed on coordinates that are strictly within the circle.

Bobon Dec 12, 2008 - 12:19:34 am UTC questionbbi5291on Dec 12, 2008 - 2:01:05 am UTC Re: question