結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー tonegawatonegawa
提出日時 2020-08-13 02:44:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,149 bytes
コンパイル時間 1,169 ms
コンパイル使用メモリ 121,912 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 01:03:10
合計ジャッジ時間 1,845 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(a, b) for(ll a=0;a<b;a++)
#define rep(a, b, c) for(ll a=b;a<c;a++)
#define lb lower_bound
#define ub upper_bound
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl factorize(ll n) {
  vvl ret;
  for(ll i = 2; i * i <= n; i++) {
    ll c = 0;
    while(n % i == 0) n /= i, c++;
    if(c!=0) ret.push_back(vll{i, c});
  }
  if(n != 1) ret.push_back(vll{n, 1});
  return ret;
}
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl f = factorize(n);
  ll ans = 1;
  ll ret = 1;
  for(auto e:f){
    if(e[1]%2) ans *= e[0];
    for(int j=0;j<e[1]/2;j++) ret *= e[0];
  }
  std::cout << ret << " " << ans << '\n';
  // n = aab

  return 0;
}
0