結果

問題 No.300 平方数
ユーザー kotamanegikotamanegi
提出日時 2016-02-12 21:12:37
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 812 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 80,280 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 04:14:24
合計ジャッジ時間 2,536 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <list>
#include <typeinfo>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
short graphing[100000000] = {};
int main() {
	long long x;
	cin >> x;
	long long hoge = sqrt(x);
	long long counter = 2;
	while (counter <= hoge) {
		if (x%counter == 0) {
			graphing[counter]++;
			x = x / counter;
		}
		else {
			counter++;
		}
	}
	long long ans = x;
	for (int i = 2;i <= hoge;++i) {
		if (graphing[i] % 2 == 1) {
			ans = ans * i;
		}
	}
	cout << ans;
}
0