結果

問題 No.300 平方数
ユーザー kichirb3kichirb3
提出日時 2018-03-25 00:05:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 910 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 78,084 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 09:01:32
合計ジャッジ時間 2,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 12 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 WA -
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.300 平方数
// https://yukicoder.me/problems/no/300
//

#include <iostream>
#include <unordered_map>
using namespace std;

long long int solve(long long int X);
unordered_map<int, int> prime_factor(long long int X);

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    long long X;
    cin >> X;

    long long ans = solve(X);
    cout << ans << endl;
}

long long int solve(long long int X) {
    unordered_map<int, int> res;
    res = prime_factor(X);
    long long ans = 1;
    for (auto f: res) {
        if (f.second % 2 == 1) {
            ans *= f.first;
        }
    }
    return ans;

}

unordered_map<int, int> prime_factor(long long int X) {
    unordered_map<int, int> res;
    for (long long i = 2; i*i <= X; ++i) {
        while (X % i == 0) {
            ++res[i];
            X /= i;
        }
    }
    if (X != 1)
        res[X] = 1;
    return res;
}
0