Find Product

 Problem:-

You have been given an array A of size N consisting of positive integers. You need to find and print the product of all the number in this array Modulo 

109+7

.

Input Format:
The first line contains a single integer N denoting the size of the array. The next line contains N space separated integers denoting the elements of the array

Output Format:
Print a single integer denoting the product of all the elements of the array Modulo 

109+7

.

Constraints:

1N103


1A[i]103

Sample Input
5
1 2 3 4 5
Sample Output
120
Time Limit: 1
Memory Limit: 256
Source Limit:

Code:-

 You can submit this solution by c++ ,c++14 or c++17.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long int ans=1,ele;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>ele;
        ans=(ans*ele)%1000000007;
    }
    cout<<ans;
    return 0;
}



Leave a Reply

Your email address will not be published.