結果

問題 No.300 平方数
ユーザー treeonetreeone
提出日時 2015-12-26 17:48:05
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 864 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 77,572 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 00:34:37
合計ジャッジ時間 1,922 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

map<lint,lint> prime_factor(lint n){
	map<lint,lint> res;
	for(lint i=2;i*i<=n;i++){
		while(n%i==0){
			++res[i];
			n/=i;
		}
	}
	if(n!=1) res[n]=1;
	return res;
}

int main(){
	lint x,y=1;
	cin>>x;
	map<lint,lint> m;
	m=prime_factor(x);
	for(map<lint,lint>::iterator it=m.begin();it!=m.end();it++){
		//o(it->fi<<" "<<it->se);
		if(it->se%2) y*=it->fi;
	}
	o(y);
}
0