codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1497E1.md (1544B)


      1 Source: https://codeforces.com/problemset/problem/1497/E1
      2 
      3 E1. Square-Free Division (easy version)
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 This is the easy version of the problem. The only difference is that in this version $k = 0$.
     22 
     23 There is an array $a_1, a_2, \ldots, a_n$ of $n$ positive integers. You should divide it into a minimal number of continuous segments, such that in each segment there are no two numbers (on different positions), whose product is a perfect square.
     24 
     25 Moreover, it is allowed to do at most $k$ such operations before the division: choose a number in the array and change its value to any positive integer. But in this version $k = 0$, so it is not important.
     26 
     27 What is the minimum number of continuous segments you should use if you will make changes optimally?
     28 
     29 Input
     30 
     31 The first line contains a single integer $t$ $(1 \le t \le 1000)$  — the number of test cases.
     32 
     33 The first line of each test case contains two integers $n$, $k$ ($1 \le n \le 2 \cdot 10^5$, $k = 0$).
     34 
     35 The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^7$).
     36 
     37 It's guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
     38 
     39 Output
     40 
     41 For each test case print a single integer  — the answer to the problem.
     42 
     43 Example
     44 
     45 Input
     46 
     47 ```
     48 3
     49 
     50 5 0
     51 
     52 18 6 2 4 1
     53 
     54 5 0
     55 
     56 6 8 1 24 8
     57 
     58 1 0
     59 
     60 1
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 3
     67 2
     68 1
     69 ```
     70 
     71 Note
     72 
     73 In the first test case the division may be as follows:
     74 
     75 * $[18, 6]$
     76 * $[2, 4]$
     77 * $[1]$