我们得到了一个机会 半圆 半径 R 我们可以取圆周上的任意一点 P 从那时起 P 在直径的两边画两条线。别管台词了 PQ 和 附言 . 任务是找到表达式的最大值 附言 2. +PQ 在一定的时间内 R
null
例如:
Input : R = 1 Output : 4.25 (4*1^2 + 0.25) = 4.25Input : R = 2Output : 16.25 (4 * 2^2 + 0.25)= 16.25
设F=PS^2+PQ。我们知道QS=2R(半圆的直径) -> 我们也知道 三角形PQS 永远都是 直角三角形 不考虑点P在圆周上的位置
1.)QS^2 = PQ^2 + PS^2 (Pythagorean Theorem)2.) Adding and Subtracting PQ on the RHS QS^2 = PQ^2 + PS^2 + PQ - PQ3.) Since QS = 2R 4*R^2 + PQ - PQ^2 = PS^2 + PQ => 4*R^2 + PQ - PQ^2 = F4.) Using the concept of maxima and minima differentiating F with respect to PQ and equating it to 0 to get the point of maxima for F i.e. 1 - 2 * PQ = 0 => PQ = 0.55.) Now F will be maximum at F = 4*R^2 + 0.25
C++
// C++ program to find // the maximum value of F #include <bits/stdc++.h> using namespace std; // Function to find the // maximum value of F double maximumValueOfF ( int R) { // using the formula derived for // getting the maximum value of F return 4 * R * R + 0.25; } // Drivers code int main() { int R = 3; printf ( "%.2f" , maximumValueOfF(R)); return 0; } |
JAVA
// JAVA program to find // the maximum value of F import java.io.*; class GFG { // Function to find the // maximum value of F static double maximumValueOfF ( int R) { // using the formula derived for // getting the maximum value of F return 4 * R * R + 0.25 ; } // Driver code public static void main (String[] args) { int R = 3 ; System.out.println(maximumValueOfF(R)); } } // This code is contributed // by anuj_67. |
Python3
# python program to find # the maximum value of F # Function to find the # maximum value of F def maximumValueOfF (R): # using the formula derived for # getting the maximum value of F return 4 * R * R + 0.25 # Drivers code R = 3 print (maximumValueOfF(R)) # This code is contributed by Sam007. |
C#
// C# program to find the // maximum value of F using System; class GFG { // Function to find the // maximum value of F static double maximumValueOfF ( int R) { // using the formula derived for // getting the maximum value of F return 4 * R * R + 0.25; } // Driver code public static void Main () { int R = 3; Console.WriteLine(maximumValueOfF(R)); } } // This code is contributed by Sam007. |
PHP
<?php // PHP program to find the // maximum value of F // Function to find the // maximum value of F function maximumValueOfF ( $R ) { // using the formula derived // for getting the maximum // value of F return 4 * $R * $R + 0.25; } // Drivers code $R = 3; echo maximumValueOfF( $R ); // This code is contributed // by anuj_67. ?> |
Javascript
<script> // javascript program to find the // maximum value of F // Function to find the // maximum value of F function maximumValueOfF(R) { // using the formula derived for // getting the maximum value of F return 4 * R * R + 0.25; } // Driver code var R = 3; document.write(maximumValueOfF(R)); // This code is contributed by bunnyram19. </script> |
输出:
36.25
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END