結果
問題 | No.1063 ルートの計算 / Sqrt Calculation |
ユーザー | scol_kp |
提出日時 | 2020-05-29 21:29:41 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,386 bytes |
コンパイル時間 | 2,347 ms |
コンパイル使用メモリ | 200,152 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-04-23 20:16:18 |
合計ジャッジ時間 | 3,057 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 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 | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
ソースコード
#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; }