15 solutions

  • 1
    @ 2022-4-4 13:54:00

    一个平方数的质因子的幂次是偶数 所以只需要在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;
    }
    

    Information

    ID
    189
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    493
    Accepted
    91
    Uploaded By