結果

問題 No.300 平方数
ユーザー kongarishisyamo
提出日時 2016-06-07 18:07:12
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 60,564 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-08 17:32:02
合計ジャッジ時間 2,631 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;

#define MAX 1000000

int main(){

	long long X,Y;
	bool zaru[MAX+1];
	vector<long long> pr;
	
	cin>>X;

	for(int i=0;i<=MAX;i++) zaru[i]=true;

	for(int i=2;i<=MAX;i++){
		if(zaru[i]){
			pr.push_back(i);
			for(int j=i*2;j<=MAX;j+=i){
				zaru[j]=false;
			}
		}
	}

	Y=1;
	for(int i=0;i<pr.size();i++){
		int c=0;
		while(X%pr[i]==0){
			c++;
			X/=pr[i];
		}
		if(c%2!=0) Y*=pr[i];
	}

	cout<<Y<<endl;

}

0