結果

問題 No.300 平方数
ユーザー kurenai3110kurenai3110
提出日時 2016-07-06 02:00:50
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 446 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 61,208 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 20:24:52
合計ジャッジ時間 1,806 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){

	long long int x;
	long long int y = 1;
	cin >> x;

	int cnt = 0;
	while (!(x%2)) {
		x = x / 2;
		cnt++;
	}
	if (cnt % 2) {
		y *= 2;
	}

	for (long long int i = 3; i*i <= x; i += 2)
	{
		cnt = 0;
		while (!(x%i)) {
			x = x / i;
			cnt++;
		}
		if (cnt % 2) {
			y *= i;
		}
		if (x == 1) break;
	}

	cout << y*x << endl;

	return 0;
}
0