結果

問題 No.300 平方数
ユーザー kurenai3110kurenai3110
提出日時 2016-07-06 00:50:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 71,788 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 22:07:01
合計ジャッジ時間 2,127 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,248 KB
testcase_01 AC 7 ms
5,376 KB
testcase_02 AC 6 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 6 ms
5,376 KB
testcase_06 AC 7 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 6 ms
5,376 KB
testcase_16 AC 6 ms
5,376 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 6 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 6 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 6 ms
5,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 6 ms
5,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool bso[1000000];

int main(){
	for (int i = 3; i < 1000000; i += 2) {
		int j;
		if (!bso[i]) {
			for (int j = i + i; j <= 1000000; j += i) {
				bso[j] = true;
			}
		}
	}

	long long int x;
	vector<pair<int, int> > ans;
	cin >> x;

	int cnt = 0;
	while (!(x%2)) {
		x = x / 2;
		cnt++;
	}
	if (cnt) {
		ans.push_back(make_pair(cnt, 2));
	}

	for (long int i = 3; i <= 1000000;) {
		cnt = 0;
		while (!(x%i)) {
			x = x / i;
			cnt++;
		}
		if (cnt) {
			ans.push_back(make_pair(cnt, i));
		}
		if (x == 1) break;
		i += 2;
		while (bso[i])i+=2;
	}

	long long int y = 1;
	for (int i = 0; i < ans.size(); i++) {
		if (ans[i].first % 2) {
			y *= ans[i].second;
		}
	}

	cout << y << endl;

	return 0;
}
0