#SP0000164. Định nghĩa kỳ lạ (Strange Definition)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Định nghĩa kỳ lạ (Strange Definition)
Strange Definition
Source: Codeforces 1470B — https://codeforces.com/problemset/problem/1470/B
Edition: Phuoc Hung OJ Extended; one dataset per program run. Subtasks are authored for PHOJ, not claimed to be official.
Problem
Two values are adjacent if is a perfect square. At each second, every entry becomes the product of all entries adjacent to it, including itself. The beauty is the maximum adjacent-group size. Answer multiple queries asking for the beauty after seconds.
Input
An integer , then integers , then followed by integer queries .
Output
Print one integer per query.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Example
Input
4
6 8 4 2
3
0
1
100
Output
2
3
3
Explanation
The square-free kernels are . At , the largest class has size ; after one second, the even-size class with kernel merges into kernel , giving beauty .