結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー ______
提出日時 2020-06-05 21:05:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,163 bytes
コンパイル時間 1,786 ms
コンパイル使用メモリ 173,112 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-16 10:50:56
合計ジャッジ時間 2,413 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

vector<long long> divisor(long long n) {
vector<long long> ret;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end()); // 昇順に並べる
return ret;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vl A=divisor(n);
    for(auto p: A){
        ll Q=n/p;
        ll q=sqrt(Q);
        if(q*q==Q){
            cout<<q<<" "<<p<<endl;fl
            return 0;
        }
    }


    return 0;
}
0