Разделите равнобедренный треугольник на две части с соотношением площадей n: m.
Учитывая высоту
равнобедренного треугольника и два целых числа
,
. Задача - найти высоту
от вершины треугольника так, что если мы сделаем разрез на высоте h сверху параллельно основанию, то треугольник нужно разделить на две части с соотношением их площадей, равным n: m .
Примеры :
Ввод: H = 4, n = 1, m = 1 Выход: 2,82843 Ввод: H = 4, n = 1, m = 0 Выход: 4
Прежде всего, прежде чем продолжить, упомянем некоторые из основных свойств равнобедренного треугольника.
Пусть ▲ ABC - равнобедренный треугольник, причем AB = AC, а BC - неравные сторона и основание треугольника. Если D - середина BC, то AD - это наша высота H. Кроме того, если мы проведем параллельную линию BC, которая разрезает AB и AC в точках E и F соответственно, и G является средней точкой EF, тогда ▲ AEG похож на ▲ ABD, ▲ AFG аналогична ▲ ACD, ▲ AEF аналогична ▲ ABC, и, используя свойства подобных треугольников, мы можем сделать следующие выводы:
AE / AB = AG / AD = EG / BD = EF / BC = AF / AC —– (i)

Согласно требованию задачи, мы должны определить высоту h, такую, чтобы отношение площади ▲ AEF к площади трапеции EFCB = n: m.
Let, h is the height of cut from the top of the triangle.
Now, area of ▲AEF = 0.5 * AG * EF and area of trapezium EFCB = 0.5 * GD * (EF+BC)
also, ratio of both is n:m.
So, we can say that ratio of area of ▲AEF to area of ▲ABC is equal to n :(n+m).
=> area of ▲AEF / area of ▲ABC = n / (n+m)
=> (0.5 * AG * EF) / (0.5 * AD * BC) = n / (n+m)
=> (AG/AD) * (EF/BC) = n / (n+m)
=> (EF/BC) * (EF/BC) = n / (n+m)
=> h2 /H2 = n / (n+m)
=> h = H*sqrt(n/(n+m))
Below is the implementation of the above approach:
C++
// C++ program, to find height h// which divide isosceles triangle// into ratio n:m#include <bits/stdc++.h>using namespace std;// Function to return the heightfloat heightCalculate(int H, int n, int m){ // type cast the n, m into float float N = n * 1.0; float M = m * 1.0; // calculate the height for cut float h = H * sqrt(N / (N + M)); return h;}// Driver codeint main(){ int H = 10, n = 3, m = 4; cout << heightCalculate(H, n, m); return 0;} |
Java
// Java program, to find height h// which divide isosceles triangle// into ratio n:mimport java.io.*;class GFG {// Function to return the heightstatic float heightCalculate(int H, int n, int m){ // type cast the n, m into float float N = (float)(n * 1.0); float M = (float)(m * 1.0); // calculate the height for cut float h = H *(float) Math.sqrt(N / (N + M)); return h;}// Driver code public static void main (String[] args) { int H = 10, n = 3, m = 4; System.out.print( heightCalculate(H, n, m)); }} |
Python3
# Python 3 program, to find height# h which divide isosceles triangle# into ratio n:mfrom math import sqrt# Function to return the heightdef heightCalculate(H, n, m): # type cast the n, m into float N = n * 1.0 M = m * 1.0 # calculate the height for cut h = H * sqrt(N / (N + M)) return h# Driver codeif __name__ == "__main__": H = 10 n = 3 m = 4 print("{0:.6}" . format(heightCalculate(H, n, m))); # This code is contributed# by Surendra_Gangwar |
C#
// C# program, to find height h// which divide isosceles triangle// into ratio n:musing System;class GFG{// Function to return the heightstatic float heightCalculate(int H, int n, int m){ // type cast the n, m into float float N = (float)(n * 1.0); float M = (float)(m * 1.0); // calculate the height for cut float h = H * (float) Math.Sqrt(N / (N + M)); return h;}// Driver codepublic static void Main (){ int H = 10, n = 3, m = 4; Console.WriteLine(heightCalculate(H, n, m));}}// This code is contributed// by inder_verma |
PHP
<?php// PHP program, to find height h// which divide isosceles triangle// into ratio n:m// Function to return the heightfunction heightCalculate($H, $n, $m){ // type cast the n, m into float $N = $n * 1.0; $M = $m * 1.0; // calculate the height for cut $h = $H * sqrt($N / ($N + $M)); return $h;}// Driver code$H = 10; $n = 3; $m = 4;echo heightCalculate($H, $n, $m);// This code is contributed// by anuj_67?> |
Javascript
<script>// JavaScript program, to find height h// which divide isosceles triangle// into ratio n:m// Function to return the heightfunction heightCalculate(H, n, m){ // type cast the n, m into float let N = n * 1.0; let M = m * 1.0; // calculate the height for cut let h = H * Math.sqrt(N / (N + M)); return h;}// Driver code let H = 10, n = 3, m = 4; document.write(heightCalculate(H, n, m));// This code is contributed by Surbhi Tyagi.</script> |
6.54654
Вниманию читателя! Не прекращайте учиться сейчас. Освойте все важные концепции DSA с помощью самостоятельного курса DSA по приемлемой для студентов цене и будьте готовы к работе в отрасли. Чтобы завершить подготовку от изучения языка к DS Algo и многому другому, см. Полный курс подготовки к собеседованию .
Если вы хотите посещать живые занятия с отраслевыми экспертами, пожалуйста, обращайтесь к Geeks Classes Live и Geeks Classes Live USA.