結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー どららどらら
提出日時 2020-05-29 21:25:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 171,032 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 20:08:22
合計ジャッジ時間 2,093 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

map<int,int> factorize(int x){
  map<int,int> ret;
  int d, q;
  while(x>=4 && x%2==0){ret[2]++; x/=2;}
  d = 3; q = x/d;
  while(q>=d){
    if(x%d==0){ ret[d]++; x=q; }else{ d+=2; }
    q=x/d;
  }
  ret[x]++;
  return ret;
}

int main(){
  int N;
  cin >> N;

  map<int,int> res = factorize(N);
  int a = 1, b = 1;
  FOR(it,res){
    int x = it->first;
    int y = it->second;
    int yy = y/2;
    int yyy = y%2;
    
    rep(i,yy) a *= x;
    rep(i,yyy) b *= x;
  }

  cout << a << " " << b << endl;
  
  
  return 0;
}

0