26 lines
672 B
Python
26 lines
672 B
Python
'''
|
|
Given an integer n, return the last two digits of the number 5 raised to the power of n. Note that n can be rather large, so direct computation may not be feasible. The task requires an efficient approach to solve the problem.
|
|
|
|
Example 1
|
|
Input:
|
|
2
|
|
Output:
|
|
25
|
|
'''
|
|
|
|
class Solution(object):
|
|
def solve(self, n:int) -> int:
|
|
print(f"n: {n}")
|
|
i = 1
|
|
pow = 1
|
|
for i in range (n):
|
|
pow *= 5
|
|
pow_str = str(pow)
|
|
result = int(pow_str[-2:])
|
|
return result
|
|
|
|
s = Solution()
|
|
print(s.solve(4)) # Output: 25
|
|
print(s.solve(100)) # Output: 25
|
|
print(s.solve(1000)) # Output: 25
|
|
print(s.solve(89)) # Output: 25 |