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 .
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 .
Constraints:
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;
}
0 Comments