結果

問題 No.300 平方数
ユーザー hotpepsihotpepsi
提出日時 2015-12-17 02:03:31
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 362 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 59,240 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-16 06:54:14
合計ジャッジ時間 1,960 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL x;
	cin >> x;
	LL r = sqrt(x);
	LL ans = 1;
	for (LL i = 2; i <= r; ++i) {
		LL cnt = 0;
		while ((x % i) == 0) {
			x /= i;
			++cnt;
		}
		if (cnt % 2) {
			ans *= i;
		}
	}
	if (x > 1) {
		ans *= x;
	}
	cout << ans << endl;
	return 0;
}
0