Product Equality

AtCoder
IDabc339_f
Time2000ms
Memory256MB
Difficulty
You are given $N$ integers $A_1, A_2, \dots, A_N$. Find the number of triples of integers $(i, j, k)$ that satisfy the following conditions: * $1 \le i, j, k \le N$ * $A_i \times A_j = A_k$ ## Constraints * $1 \le N \le 1000$ * $\color{red}{1 \le A_i < 10^{1000}}$ ## Input The input is given from Standard Input in the following format: $N$ $A_1$ $A_2$ $\vdots$ $A_N$ [samples]
Samples
Input #1
5
2
3
6
12
24
Output #1
6

The following six triples $(i, j, k)$ satisfy the conditions in the problem statement:

*   $(1, 2, 3)$
*   $(1, 3, 4)$
*   $(1, 4, 5)$
*   $(2, 1, 3)$
*   $(3, 1, 4)$
*   $(4, 1, 5)$
Input #2
11
1
2
3
4
5
6
123456789123456789
123456789123456789
987654321987654321
987654321987654321
121932631356500531347203169112635269
Output #2
40

Note that the values of each integer $A_i$ can be huge.
Input #3
9
4
4
4
2
2
2
1
1
1
Output #3
162

Note that there may be duplicates among the values of $A_i$.
API Response (JSON)
{
  "problem": {
    "name": "Product Equality",
    "description": {
      "content": "You are given $N$ integers $A_1, A_2, \\dots, A_N$.   Find the number of triples of integers $(i, j, k)$ that satisfy the following conditions: *   $1 \\le i, j, k \\le N$ *   $A_i \\times A_j = A_k$",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc339_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given $N$ integers $A_1, A_2, \\dots, A_N$.  \nFind the number of triples of integers $(i, j, k)$ that satisfy the following conditions:\n\n*   $1 \\le i, j, k \\le N$\n*   $A_i \\times A_j = A_k$\n\n##...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments