結果

問題 No.300 平方数
ユーザー E31415926
提出日時 2016-03-31 16:51:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 358 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 59,500 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-02 08:29:45
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	long long x, y = 1, n = 0, i;
	cin >> x;
	while (x % 2 == 0) {
		x /= 2;
		n++;
	}
	if (n % 2 != 0) {
		y *= 2;
	}
	for (i = 3; i <= sqrt(x); i += 2) {
		n = 0;
		while (x % i == 0) {
			x /= i;
			n++;
		}
		if (n % 2 != 0) {
			y *= i;
		}
	}
	y *= x;
	cout << y << endl;
	return 0;
}
0