結果
| 問題 |
No.1063 ルートの計算 / Sqrt Calculation
|
| コンテスト | |
| ユーザー |
scol_kp
|
| 提出日時 | 2020-05-29 21:29:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,386 bytes |
| コンパイル時間 | 2,248 ms |
| コンパイル使用メモリ | 198,472 KB |
| 最終ジャッジ日時 | 2025-01-10 16:32:31 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
#define FASTIO
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ll power(ll a, ll n) {
ll res = 1;
for (; n > 0; n >>= 1) {
if (n & 1) res *= a;
a *= a;
}
return res;
}
void solve() {
ll N;
cin >> N;
unordered_map<ll, ll> factors;
for (ll i = 2; i * i <= N; i++) {
while (N % i == 0) {
++factors[i];
N /= i;
}
}
if (N > 1) ++factors[N];
ll a = 1, b = 1;
for (const auto& [v, d] : factors) {
if (d & 1) {
b *= v;
a *= power(v, d / 2);
}
else {
a *= power(v, d / 2);
}
}
cout << a << " " << b << "\n";
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
int main() {
#ifdef FASTIO
cin.tie(0), cout.tie(0);
ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
ifstream ifs("./in_out/input.txt");
cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
ofstream ofs("./in_out/output.txt");
cout.rdbuf(ofs.rdbuf());
#endif
solve();
cout << flush;
return 0;
}
scol_kp