P26545 [AtCoder] Multiplication
普及+
题目描述

Problem Description

Aoi, a student at JOI High School, found a scroll in the library. The scroll contains $ N $ integers written in a row, where the $ i $th number ($1 \leq i \leq N$) from the left is $ A_i $.

Aoi wondered, "Out of these $ N $ integers, how many ways are there to choose 3 integers such that, when they are taken in order from left to right as $ x, y, z $, the equation $x \times y = z$ holds?"

Given the $ N $ integers written on the scroll, create a program to find the answer to Aoi's question.

Input Format

The input is given from the standard input in the following format:

$ N $ $ A_1 $ $ A_2 $ $\cdots$ $ A_N $

Output Format

Output the answer to Aoi's question on a single line to the standard output.

Sample Input and Output

Sample Input #1

3
21 13 273

Sample Output #1

1

Sample Input #2

3
10 5 2

Sample Output #2

0

Sample Input #3

5
4 2 2 8 16

Sample Output #3

4

Sample Input #4

10
1 1 1 1 1 1 1 1 1 1

Sample Output #4

120

Notes/Hints

Constraints

  • $3 \leq N \leq 100$.
  • $1 \leq A_i \leq 999$ ($1 \leq i \leq N$).
  • All input values are integers.

Subtasks

  1. ($ 20 $ points) $ N = 3 $.
  2. ($ 80 $ points) No additional constraints.

Grading Notes

All submissions are graded on the judge system.

A submitted source code is considered correct for a subtask if it returns the correct result for all test inputs corresponding to that subtask.

The score for each submission is the sum of the points awarded for the subtasks that the submitted source code is considered correct for.

The score for this task is the maximum score of all submissions for this task.

The current score can be checked under the "My Score Status" tab in the "Submission Results".

Sample Explanation 1

Choosing $ A_1, A_2, A_3 $ results in $21 \times 13 = 273$. Therefore, the answer to Aoi's question is $ 1 $ way. This input example satisfies the constraints for all subtasks.

Sample Explanation 2

Choosing $ A_1, A_2, A_3 $ does not result in $10 \times 5 = 2$. Therefore, the answer to Aoi's question is $ 0 $ ways. This input example satisfies the constraints for all subtasks.

Sample Explanation 3

There are $ 4 $ ways to choose 3 integers such that, when taken in order from left to right as $ x, y, z $, the equation $x \times y = z$ holds:
- Choosing $ A_1, A_2, A_4 $ results in $4 \times 2 = 8$.
- Choosing $ A_1, A_3, A_4 $ results in $4 \times 2 = 8$.
- Choosing $ A_2, A_4, A_5 $ results in $2 \times 8 = 16$.
- Choosing $ A_3, A_4, A_5 $ results in $2 \times 8 = 16$.
This input example satisfies the constraints for subtask 2.

Sample Explanation 4

This input example satisfies the constraints for subtask 2.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 21 13 273
样例输出
1