結果

問題 No.300 平方数
ユーザー ninoinui
提出日時 2020-07-18 04:25:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 1,000 ms
コード長 341 bytes
コンパイル時間 2,052 ms
コンパイル使用メモリ 199,900 KB
最終ジャッジ日時 2025-01-11 23:58:38
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

map<long, int> pf(long n) {
  map<long, int> ma;
  for (long i = 2; i * i <= n; i++) {
    while (n % i == 0) ma[i]++, n /= i;
  }
  if (n != 1) ma[n]++;
  return ma;
}

int main() {
  long x;
  cin >> x;
  long ans = 1;
  for (auto [a, b] : pf(x)) if (b % 2) ans *= a;
  cout << ans << "\n";
}
0