結果

問題 No.300 平方数
ユーザー おいがみ
提出日時 2015-11-13 23:12:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 1,539 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 169,356 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 15:08:39
合計ジャッジ時間 2,829 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef MYDEBUG
#include <bits/stdc++.h>
#define err(...)
#define errs(...)
#endif

using namespace std;
void Calc();
#define ALL(a) begin(a),end(a)
#define RALL(a) rbegin(a),rend(a)
typedef long long ll;
typedef unsigned long long ull;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  cin.exceptions(istream::failbit | istream::badbit);
  Calc();
  cout.flush();
  return 0;
}

struct Scanner {
  template<class A = string>static A Next() { A a; cin >> a; return a; }
  static string Line() { string s; getline(cin, s); return s; }
  template<class A = int> static vector<A> Array(int n) {
    vector<A> a(n); for (A& i : a) i = Next<A>(); return a;
  }
  template<class A = int> static vector<A> Array(int n, A add) {
    vector<A> a(n); for (A& i : a) i = Next<A>() + add; return a;
  }
  static int Int() { return Next<int>(); }
  template<class A> A operator-(const A &a) { return Next<A>() - a; }
  template<class A> Scanner& operator>>(A &a) { a = Next<A>(); return *this; }
  template<class A> operator A() { return Next<A>(); }
  operator bool() { return !!cin; }
};
Scanner in;

/*---------------------------------------------------------------------*/

void Calc() {
  ll x = in;
  map<ll, ll> m;
  auto xx = sqrt(x);
  int cnt = 0;
  for (int i = 2; x != 1 && i <= xx; i++) {
    cnt++;
    while (x % i == 0) {
      x /= i;
      m[i]++;
    }
  }
  if (x != 1) m[x]++;
  ll y = 1;
  for (auto& i : m) {
    if (i.second % 2)
      y *= i.first;
  }
  cout << y << endl;
}
0