- Integers in Python can be as big as the bytes in your machine's memory. There is no limit in size as there is: 231-1 (c++ int) or 263-1 (C++ long long int).
- As we know, the result of ab grows really fast with increasing b.
- Read four numbers, a, b, c, and d, and print the result of ab + cd.
- Integers a, b, c, and d are given on four separate lines, respectively.
- 1 <= a <= 1000
- 1 <= b <= 1000
- 1 <= c <= 1000
- 1 <= d <= 1000
Output Format:
- Print the result of ab + cd on one line.
9
29
7
27
Sample Output:4710194409608608369201743232
Note: This result is bigger than 263-1. Hence, it won't fit in the long long int of C++ or a 64-bit integer.
Solution:
a,b,c,d = (int(input()) for _ in range(4))
print (pow(a,b)+pow(c,d))
Disclaimer: The problem statement is given by hackerrank.com but the solution is generated by the Geek4Tutorial admin. If there is any concern regarding this post or website, please contact us using the contact form. Thank you!
No comments:
Post a Comment