We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #199: Iterative Circle Packing

Project Euler #199: Iterative Circle Packing

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 199 from projecteuler.net

circles of equal radius are placed inside a larger circle such that each consecutive pair of inner circles is tangent to one another, all the inner circles are tangent to the larger one and do not overlap. There are uncovered "gaps" which are to be filled iteratively with more tangent circles.

Picture for

At each iteration, a maximally sized circle is placed in each gap, which creates more gaps for the next iteration. After iterations (pictured), there are gaps and the fraction of the area which is not covered by circles is , rounded to eight decimal places.

What fraction of the area is not covered by circles after iterations?

Input Format

Each test file contains exactly two integers separated by a single space: and .

Constraints

Output Format

Output exactly one number that is the area not covered by circles after all iterations. Your answer will be considered as correct if the absolute difference between it and the author's one does not exceed .

Sample Input 0

3 3

Sample Output 0

0.067903417174

Sample Input 1

4 1

Sample Output 1

0.166522241370

Explanation 1

image

The initial circles use of the big circle's space. The green circles added at the first iteration use of the space.

Author

bayleef

Difficulty

Easy

Max Score

100

Submitted By

127

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature