Counting Columns

You are standing inside an ancient Measharan monument. It consists of an
infinite number of regular hexagonal columns, arranged in a regular
hexagonal grid. Each edge of each column is parallel to some line
segment between the two nearest columns (like on the picture).

[image]

Given the distance between two columns d and the edge length of each
column r, compute the number of columns that you can see.

Input

Input consists of several cases. Each case consists of two positive
integers: d (distance between the centers of two columns), r (the edge
length of each column). You can assume that 2r < d, and that
1 ≤ d, r ≤ 10000.

After the last case the input contains a line containing 0 0.

Output

Output the number of visible columns.

We have three consonants and two wovels, say, a, b, c, d, e. According
to our definition, there are 5 words of length 1 (all letters), and 25
words of length 2 (all possible pairs of letters). At length 3 the
answer is 98 (out of 5³ possible words, 3³ consists of only wovels,
which makes them illegible).

Problem information

Author: Eryk Kopczynski

Generation: 2026-01-25T23:03:57.593Z

© Jutge.org, 2006–2026.
https://jutge.org
