Greater power
Easy Accuracy: 0.0% Submissions: 17 Points: 2

Given four integers a, b, m, n . Find whether  pow(a,b) is greater than pow(m,n) or not. Where pow(x,y) denotes x raised to the power y. Output 1 if pow(a,b) is greater, output 0 if pow(m,n) is greater otherwise output -1 if both are equal.

 

Example 1:

Input:
a = 2 , b = 2 , m = 3 , n = 2
Output:
0
Explanation:
22 = 4, and 32 = 9. 9>4. So,
the Output 0.

Example 2:

Input:
a = 1 , b = 23 , m = 1 , n = 989
Output:
-1
Explanation:
Both 123 and 1989 = 1. So,
the Output is -1. 

 

Your Task:
You don't need to read input or print anything. Your task is to complete the function greaterPower() which takes 4 Integers a,b,m and n as input and returns the answer.

 

Expected Time Complexity: O(max(log(a),log(m))
Expected Auxiliary Space: O(1)

 

Constraints:
0 <= b,n <= 1018
1 <= a,m <= 1018

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window