#P10724. [GESP202406 七级] 区间乘积

[GESP202406 七级] 区间乘积

Background

Related multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1155.

Problem Description

Xiao Yang has a sequence A=[a1,a2,,an]A=[a_1,a_2,\ldots,a_n] containing nn positive integers.

Xiao Yang wants to know how many pairs l,r(1lrn)\langle l,r\rangle(1\leq l\leq r\leq n) satisfy that al×al+1××ara_l\times a_{l+1}\times\ldots\times a_r is a perfect square.

A positive integer xx is a perfect square if and only if there exists a positive integer yy such that x=y×yx=y\times y.

Input Format

The first line contains a positive integer nn, representing the number of positive integers.

The second line contains nn positive integers aia_i, representing the sequence AA.

Output Format

Output an integer, representing the number of l,r\langle l,r\rangle pairs that meet the requirement.

5
3 2 4 3 2
2

Hint

Sample Explanation

The l,r\langle l,r\rangle pairs that satisfy the condition are 1,5\langle 1,5\rangle and 3,3\langle 3,3\rangle.

Constraints

Subtask ID Percentage nn aia_i
11 20%20\% 105\leq 10^5 1ai21\leq a_i\leq 2
22 40%40\% 100\leq 100 1ai301\leq a_i\leq 30
33 105\leq 10^5

Translated by ChatGPT 5