Input
The first line of input contains an integer n, which is the number of elements in the given array. The second line of input contains n space separated integers, which are the elements of the given array.
Output
Print the last two digits of the product of the array values. Note that you always need to print two digits.
Constraints
1 <= n <= 100 1 <= arr[i] <= 100. arr[i] is the ith element of the given array.
Example #1
Input 2 25 10 Output 50 Explanation: 25 * 10 = 250
Advertisement
Answer
You can try this (it’s version of Python3):
n = int(input()) arr = list(map(int, input().rstrip().split())) result = 1 for num in arr: result = (result * num) % 100 print("{:02d}".format(result))
A little bit modify for better algorithm:
n = int(input()) arr = list(map(int, input().rstrip().split())) result = 1 for num in arr: result = (result * num) % 100 if(result==0): break # 0 multiply by any number still be 0 print("{:02d}".format(result))