結果

問題 No.300 平方数
ユーザー Ysmr_Ry
提出日時 2016-03-03 20:50:39
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 532 bytes
コンパイル時間 620 ms
コンパイル使用メモリ 66,852 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 13:58:02
合計ジャッジ時間 1,822 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder 300 (http://yukicoder.me/problems/817)
#include<iostream>
#include<map>
#define itr(it,a) for(auto it=(a).begin();it!=(a).end();++it)

typedef long long ll;

ll X;

std::map<ll, ll> prime_factor( ll n )
{
	std::map<ll, ll> ret;

	for( ll i = 2; i*i <= n; ++i ) while( n % i == 0 )
	{
		n /= i;
		++ret[i];
	}

	if( n != 1 )
		++ret[n];

	return ret;
}

int main()
{
	std::cin >> X;

	auto m = prime_factor( X );

	ll Y = 1;
	itr( it, m ) if( it->second&1 )
		Y *= it->first;

	std::cout << Y << std::endl;

	return 0;
}
0