結果

問題 No.1063 ルートの計算 / Sqrt Calculation
コンテスト
ユーザー zeronosu77108
提出日時 2020-06-23 20:51:11
言語 C++17(clang)
(clang++ 23.1.3 + boost 1.92.0 + ACL)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 329µs
コード長 575 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 917 ms
コンパイル使用メモリ 132,516 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-10-12 07:45:17
合計ジャッジ時間 2,109 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0