Zeroes
Practice
3.8 (70 votes)
Ready
Mathematics
Medium
Problem
84% Success 3833 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given an array A containing N integers. Let P be the product of all the elements of A. Your task is to answer Q queries. Each query consists of a single integer X. In order to answer a query, you have to find the number of trailing 0's in P represented in base X.
For more information about base representation of a number, please refer here.
Constraints
1 ≤ N, Ai, Q ≤ 105
2 ≤ X ≤ 105
Input format
The first line contains a single integer N. The second line contains N space separated integers, representing the array A. The third line contains a single integer Q. Next Q lines follow, each containing a single integer X, denoting a single query.
Output format
Output exactly Q lines. In the ith of them, output the answer to the ith query.
Submissions
Please login to view your submissions
Similar Problems
Points:30
2 votes
Tags:
MathematicsMediumOpenApproved
Points:30
99 votes
Tags:
MathematicsMediumOpenApproved
Editorial