求代码比较
查看原帖
求代码比较
637788
kimi0705楼主2023/7/30 17:26

蒟蒻的代码

#include <bits/stdc++.h>
#pragma GCC optimize(3,"Ofast")
#define int long long
using namespace std;
const int K = 1e3 + 10;
const int L = 1e4 + 10;
const int M = 1e5 + 10;
const int N = 1e6 + 10;
int t, n, k, ans;
int a[2 * M];
map<int, bool> Map;
signed main() {
	//	freopen (".\\data\\in.txt", "r", stdin);
	//	freopen (".\\data\\out.txt", "w", stdout);
	ios::sync_with_stdio (false);
	cin.tie (0);
	cout.tie (0);
	cin >> t;
	while (t--) {
		Map.clear();
		cin >> n >> k;
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			for (int j = 2; j * j <= a[i]; j++)
				while (a[i] % (j * j) == 0)
					a[i] /= j * j;
		}
		ans = 0;
		for (int i = 1; i <= n; i++) {
			if(Map[a[i]]) ans++, Map.clear();
			Map[a[i]] = 1;
		}
		cout << ans + 1 << '\n';
	}
	return 0;
}
/*
    ┏━━┛   ┻━━━━━━━┛   ┻┓
    ┃          ┃
    ┃    ━━     ┃
    ┃   ┳━┛     ┗━┳    ┃
    ┃          ┃
    ┃     ┻     ┃
    ┃            ┃
    ┗━┓   ┏━━━━━━━━━━┛
    ┃   ┃   神兽保佑
    ┃   ┃   AC Accept 得分100!
    ┃   ┗━━━━━━━━━━━━━━━┓
    ┃            ┃
    ┃            ┃
    ┗━┓━┓━┏━┓━┳ ━━━┓━┓━┏━┓━┳
      ┃   ┫   ┫    ┃   ┫   ┫
      ┗━┻━┛━━━┗    ┗━┻━┛━━━┗
*/
2023/7/30 17:26
加载中...