結果

問題 No.300 平方数
ユーザー legosuke
提出日時 2017-12-10 05:26:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 350 bytes
コンパイル時間 1,507 ms
コンパイル使用メモリ 157,656 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 07:35:59
合計ジャッジ時間 2,751 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(void) {
  ll x;
  cin >> x;

  ll ans = 1;
  for (ll i = 2; i * i <= x; i++) {
    if (x % i) continue;
    int cnt = 0;
    while (x % i == 0) {
      x /= i;
      cnt++;
    }
    if (cnt & 1) ans *= i;
  }
  if (x != 1) ans *= x;
  cout << ans << endl;

  return 0;
}
0