結果
問題 | No.1063 ルートの計算 / Sqrt Calculation |
ユーザー |
|
提出日時 | 2020-06-23 20:51:11 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 575 bytes |
コンパイル時間 | 950 ms |
コンパイル使用メモリ | 132,240 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 18:42:48 |
合計ジャッジ時間 | 1,667 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <utility> #include <algorithm> #include <climits> #include <map> using namespace std; void diviser(int n, map<int,int>& mp) { while(n%2==0) n/=2,mp[2]++; for (int i=3; i*i<=n; i++) { while(n%i==0) n/=i,mp[i]++; } if (n!=1) mp[n]++; } int main() { int n; cin >> n; map<int,int> mp; diviser(n,mp); int ans1=1, ans2=1; for (auto [a,b] : mp) { for (int i=0; i<b/2; i++) ans1*=a; if (b%2) ans2 *= a; } cout << ans1 << " " << ans2 << endl; }