Dados X e Y cuyos valores son mayores que 2, la tarea es encontrar cuál es el máximo entre
x^(y^2) y y^(x^2)
Considere que x es mayor que y o y es mayor que x . Entonces, imprime 1 si x^(y^2) es mayor o 2 si y^(x^2) es mayor.
Ejemplos:
Input: X = 4, Y = 9 Output: 1 Input: X = 4, Y = 3 Output: 2
Enfoque: Asumir
*** QuickLaTeX cannot compile formula: *** Error message: Error: Nothing to show, formula is empty
, luego de tomar ln en ambos lados y dividir por
*** QuickLaTeX cannot compile formula: *** Error message: Error: Nothing to show, formula is empty
podemos obtener
*** QuickLaTeX cannot compile formula: *** Error message: Error: Nothing to show, formula is empty
.
Tomar
*** QuickLaTeX cannot compile formula: *** Error message: Error: Nothing to show, formula is empty
. Esta función es monótonamente decreciente para
*** QuickLaTeX cannot compile formula: *** Error message: Error: Nothing to show, formula is empty
.
If x > y, then F(x) < F(y)
C++
// C++ program to find the greater value #include <bits/stdc++.h> using namespace std; // Function to find maximum bool findGreater(int x, int y) { // Case 1 if (x > y) { return false; } // Case 2 else { return true; } } // Driver Code int main() { int x = 4; int y = 9; findGreater(x, y) ? cout << "1\n" : cout << "2\n"; return 0; }
Java
// Java program to find // the greater value import java.io.*; class GFG { // Function to find maximum static boolean findGreater(int x, int y) { // Case 1 if (x > y) { return false; } // Case 2 else { return true; } } // Driver Code public static void main (String[] args) { int x = 4; int y = 9; if(findGreater(x, y)) System.out.println("1"); else System.out.println("2"); } } // This code is contributed // by inder_verma.
Python3
# Python3 program to find # the greater value # Function to find maximum def findGreater(x, y): # Case 1 if (x > y): return False; # Case 2 else: return True; # Driver Code x = 4; y = 9; if(findGreater(x, y)): print("1"); else: print("2"); # This code is contributed # by mits
C#
// C# program to find // the greater value using System; class GFG { // Function to find maximum static bool findGreater(int x, int y) { // Case 1 if (x > y) { return false; } // Case 2 else { return true; } } // Driver Code public static void Main () { int x = 4; int y = 9; if(findGreater(x, y)) Console.WriteLine("1"); else Console.WriteLine("2"); } } // This code is contributed // by inder_verma.
PHP
<?php // PHP program to find the greater value // Function to find maximum function findGreater($x, $y) { // Case 1 if ($x > $y) { return false; } // Case 2 else { return true; } } // Driver Code $x = 4; $y = 9; if(findGreater($x, $y) == true) echo("1\n"); else echo("2\n"); // This code is contributed // by inder_verma ?>
Javascript
<script> // JavaScript program to find // the greater value // Function to find maximum function findGreater(x,y) { // Case 1 if (x > y) { return false; } // Case 2 else { return true; } } // Driver Code var x = 4; var y = 9; if(findGreater(x, y)) document.write("1"); else document.write("2"); // This code is contributed by 29AjayKumar </script>
Producción:
1