一个平方数的质因子的幂次是偶数 所以只需要在n中找到质因子的幂次是奇数的就可以了
#include <iostream> #include <cstring> #include <algorithm> using namespace std; int main() { long long n; cin >> n; for (long long i = 2; i <= n / i; i ++ ) { while (n % (i * i) == 0) n /= (i * i); } cout << n << endl; }
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.
Using your 追梦算法网 universal account