結果

問題 No.300 平方数
コンテスト
ユーザー kuisiba
提出日時 2016-10-28 17:47:05
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 1,000 ms
+ 324µs
コード長 463 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 330 ms
コンパイル使用メモリ 71,868 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-09-29 00:35:55
合計ジャッジ時間 2,381 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <cstdint>

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  int64_t n;
  cin >> n;
  if (n == 1) {
    cout << "1" << endl;
    return 0;
  }
  int64_t ans = 1;
  int count = 0;
  for (int64_t i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      count++;
    }
    if (count & 1) {
      ans *= i;
    }
    count = 0;
  }
  if (n > 1) {
    ans *= n;
  }
  cout << ans << endl;
}
0