Irreducible Fractions
Time limit3sMemory limit2048 MB
Count ordered index quadruples (i, j, k, l) of distinct positions so that (a_i * a_j) / (a_k * a_l) is an irreducible fraction, with n up to 2000 and values up to 1e12.
- Level
Medium6 of 10
- Topics
- Number theory, Bit manipulation, Combinatorics
- Solved
- No attempts yet
Problem
Given an array of positive integers, count the quadruples of distinct indices for which the following fraction is irreducible:
Input
The first line contains an integer (), the length of the array. The second line contains integers (), the elements of the array.
Output
Print a single integer: the number of quadruples that satisfy the condition.