LCC '21 Contest 1 S4 - Perfect Squares

View as PDF

Submit solution


Points: 15 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

Bob loves squares! More specifically, he loves perfect squares. He has a collection of N cards, numbered from 0 to N-1, each with a value written on it.

Bob has Q queries of the form l r. He would like to know if the product of the values on the cards l to r, inclusive would form a perfect square.

Input Specification

The first line contains two integers, N and Q, such that N, Q (1 \le N, Q \le 10^5)

The second line contains N integers, the values on the cards, a_i (1 \le a_i \le 10^5)

The next Q lines, contain queries of the form l r such that l, r (0 \le l \le r < N)

Output Specification

For each query, print on a separate line yes if the product is a perfect square and no if it is not.

Subtasks

Subtask 1 (30%)

N, Q, a_i \le 1000

Subtask 2 (70%)

No further constraints.

Sample Input

4 3
9 3 5 15
0 0
1 2
1 3

Sample Output

yes
no
yes

Sample Explanation 1

From 0 to 0, the only number is 9, which is a perfect square.

From 1 to 2, the product is 15, which is not a perfect square.

From 1 to 3, the product is 225, which is a perfect square.


Comments

There are no comments at the moment.