結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー 👑 zeronosu77108zeronosu77108
提出日時 2020-06-23 20:51:11
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 1,002 ms
コンパイル使用メモリ 132,372 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 22:01:51
合計ジャッジ時間 1,674 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 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 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 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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