結果

問題 No.300 平方数
ユーザー springroll
提出日時 2018-11-18 18:36:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 454 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 175,184 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-12-24 15:00:34
合計ジャッジ時間 35,719 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 TLE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

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

int main() {
	ll X, Y=1;
	cin >> X;

	map<ll,ll> m;
	m = prime_factor(X);

	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if (itr->second % 2 != 0) {
			Y *= itr->first;
		}
	}
	cout << Y << endl;
}
0