結果
| 問題 |
No.1063 ルートの計算 / Sqrt Calculation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-19 11:20:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 704 bytes |
| コンパイル時間 | 1,853 ms |
| コンパイル使用メモリ | 176,352 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-17 19:16:16 |
| 合計ジャッジ時間 | 2,773 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:26:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
26 | for (const auto& [key, value] : dic) {
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
int main() {
long long N; cin >> N;
map<int,int> dic;
int count = 0;
while(true) {
bool fire = false;
for(int i = 2; i <= sqrt(N); i++) {
if(N % i == 0) {
N /= i;
dic[i]++;
fire = true;
break;
}
}
if(fire == false) {
break;
}
}
dic[N]++;
int ans = 1;
int a = 1;
for (const auto& [key, value] : dic) {
if(value % 2 == 0) {
int x = value / 2;
ans *= pow(key,x);
}else {
int x = (value - 1) / 2;
ans *= pow(key,x);
a *= key;
}
}
cout <<ans<< " " << a << endl;
}