Divide Array
Practice
3.2 (47 votes)
Approved
Basic programming
Easy
Math
Open
Problem
90% Success 22109 Attempts 20 Points 3s Time Limit 256MB Memory 1024 KB Max Code

Given an array A of size N. Given Q operations, each operation contains an integer D. In each operation you have to divide all the elements of the array by D.

For example, for each operation with a given D, the new array A would be:

A[0] / D, A[1] / D, A[2] / D, ..... , A[N-1] / D

Finally, after processing all the operations you have to print the final array after Q operations.
Note : The result of the each division will be an integer, for example 5 / 2 = 2

Input :
First line of input contains a single integer N denoting number of elements in the array A. Next line of input contains N space separated integers denoting the elements of array A. Next line contains Q denoting number of operations. Next Q lines contains a single integer D by which divide the elements of the array.

Output :
Print single line containing N space separated integers after processing Q operations.

Constraints:
1<=N<=100000
1<=Ai<=1000000
1<=Q<=100000
1<=D<=1000

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
12 votes
Tags:
Ad-HocAlgorithmsApprovedEasyImplementationOpen