結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー m1025o1184tm1025o1184t
提出日時 2020-05-29 21:37:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 1,494 ms
コンパイル使用メモリ 169,608 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 20:33:34
合計ジャッジ時間 2,073 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	map<ll, ll> mp;
	for (ll i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			mp[i]++;
		}
	}
	if (n != 1) mp[n]++;
	ll a = 1, b = 1;
	for (auto& c : mp) {
		if (c.second % 2 == 1) {
			while (c.second > 1) {
				a *= c.first;
				c.second -= 2;
			}
			b *= c.first;
		}
		else {
			a *= (ll)pow(c.first, c.second / 2);
		}
	}
	cout << a << ' ' << b << endl;
 	return 0;
}
0