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

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Fundamentals
  4. Minimum Height Triangle

Minimum Height Triangle

Problem
Submissions
Leaderboard
Discussions
Editorial

Given integers and , find the smallest integer , such that there exists a triangle of height , base , having an area of at least .

image

Example

The minimum height is . One example is a triangle formed at points (0, 0), (4, 0), (2, 3).

Function Description

Complete the lowestTriangle function in the editor below.

lowestTriangle has the following parameters:

  • int b: the base of the triangle
  • int a: the minimum area of the triangle

Returns

  • int: the minimum integer height to form a triangle with an area of at least

Input Format

There are two space-separated integers and , on a single line.

Constraints

Sample Input 0

2 2

Sample Output 0

2

Explanation 0

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: :

image

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

Sample Input 1

17 100

Sample Output 1

12

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: .

image

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

Author

pkacprzak

Difficulty

Easy

Max Score

10

Submitted By

65883

Need Help?


View discussions
View editorial
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