HackerRank : Ad Infinitum18 – Minimum Height Triangle

By | June 10, 2017
Minimum Height Triangle: Hackerrank
Given integers b and  a, find the smallest integer h , such that there exists a triangle of height  h, base  b, having an area of at least  a.


Input Format

In the first and only line, there are two space-separated integers b and a , denoting respectively the base of a triangle and the desired minimum area.

Output Format

In a single line, print a single integer h, denoting the minimum height of a triangle with base b and area at least a.

Sample Input 0

2 2

Sample Output 0


Sample Input 1

17 100

Sample Output 1


Explanation 1

The task is to find the smallest integer height of the triangle with base and area at least . It turns out, that there are triangles with height , base and area , for example a triangle with corners in the following points: .


It can be proved that there is no triangle with integer height smaller than , base and area at least .


Pretty easy problem. Simple area calculations.