Array Product Without Division

VERY EASY · C · 2000ms

Head judge Wasif is finalizing the university's flagship contest problem set and starts with a classic: given N numbers, report for each position the product of all OTHER numbers, without ever dividing. Given N integers, print an array where output[i] = product of all elements except a[i], WITHOUT using division, in O(N) time.

Input

Line1: N. Line2: N integers.

Output

N integers, space-separated.

Constraints

1 ≤ N ≤ 10^5, values fit in signed 64-bit after multiplication

Sample Input

4
1 2 3 4

Sample Output

24 12 8 6
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Array Product Without Division · DIU ContestHub