# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
110592022 |
Practice:
chauhan14 |
1497E1
- 37
|
C++14 (GCC 6-32)
|
Accepted
|
1684 ms
|
7240 KB
|
2021-03-21 10:08:53 |
2021-03-21 10:08:53 |
|
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll int
using pss = pair<string, string>;
using pll = pair<ll, ll>;
using pls = pair<ll,string>;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define endl '\n';
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const long long mod = 1 * 1e7 + 7;
set<ll> st;
ll findval(ll n)
{
ll ans=1,tag=0;
for(ll i=2;i*i<=n;i++)
{
if(n%i) continue;
for(tag=0;n%i==0;n/=i,tag^=1)
{}
if(tag)
ans*=i;
}
return ans*n;
}
int main()
{
IO;
ll i=0, j=0, n=0, m=0, k=0, t=0;
cin>>t;
while(t--)
{
cin>>n>>k;
vector<ll> a(n);
st.clear();
for(i=0;i<n;i++)
{
cin>>a[i];
a[i]=findval(a[i]);
}
ll ans=1;
st.insert(a[0]);
for(i=1;i<n;i++)
{
if(st.find(a[i])!=st.end())
{
ans++;
st.clear();
st.insert(a[i]);
}
else st.insert(a[i]);
}
cout<<ans<<endl;
}
return 0;
}
Click to see test details