結果

問題 No.300 平方数
ユーザー agatan
提出日時 2015-12-02 15:23:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 73,844 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-14 07:52:48
合計ジャッジ時間 1,909 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 10 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <array>
#include <vector>
#include <unordered_map>
#include <iostream>

using namespace std;

#define REP(i, N) for(i = 0; i < N; ++i)

typedef long long ll;

void solve() {
    int x;
    cin >> x;
    unordered_map<ll, int> primes;
    for (ll i = 2; i * i <= x; ++i) {
        while (x % i == 0) {
            primes[i]++;
            x /= i;
        }
    }
    if (x != 1) primes[x] = 1;

    ll ans = 1;
    for (auto&& i: primes) {
        if (i.second % 2) {
            ans *= i.first;
        }
    }

    cout << ans << endl;

}


int main(int argc, char const* argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0