-6

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 i​th​ element of the given array.

Example #1

Input
2
25 10
Output
50
Explanation: 25 * 10 = 250
Community
  • 1
  • 1
mihrex
  • 1
  • 1
  • 3
  • Hi @mihrex, could you clarify exactly what is the question here? This looks like a copy-paste of an exercise. Please write a specific technical question related to this problem, along with what you have tried and what error or unexpected behaviour you are getting. – Yacine Mahdid Feb 09 '20 at 02:32

2 Answers2

0

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))
loginmind
  • 563
  • 5
  • 11
-2

Java.

private static String display(List<Integer> ary) {
        int tempresult = 1;

        if (ary.size() == 0)
            return "0";
        else {
            for (int j = 0; j < ary.size(); j++) {
                tempresult *= ary.get(j);
            }

            int result = tempresult % 100;

            if (result < 10) {
                return "0" + result;
            }

            else
                return String.valueOf(result);
        }

    }`

The output should of 2 characters, so if the result is 1 char needs to convert into 2 then print the result.

Buddy Bob
  • 5,829
  • 1
  • 13
  • 44
Zoro
  • 1
  • 1