結果

問題 No.300 平方数
ユーザー wonda_t_coffeewonda_t_coffee
提出日時 2020-02-27 23:54:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 910 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 78,408 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 17:07:48
合計ジャッジ時間 2,517 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 33 ms
6,944 KB
testcase_14 AC 5 ms
6,948 KB
testcase_15 AC 18 ms
6,940 KB
testcase_16 AC 15 ms
6,940 KB
testcase_17 AC 33 ms
6,944 KB
testcase_18 AC 4 ms
6,944 KB
testcase_19 AC 13 ms
6,940 KB
testcase_20 AC 7 ms
6,940 KB
testcase_21 AC 30 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 25 ms
6,940 KB
testcase_24 AC 18 ms
6,940 KB
testcase_25 AC 25 ms
6,940 KB
testcase_26 AC 23 ms
6,944 KB
testcase_27 AC 16 ms
6,944 KB
testcase_28 AC 26 ms
6,940 KB
testcase_29 AC 28 ms
6,944 KB
testcase_30 AC 29 ms
6,940 KB
testcase_31 WA -
testcase_32 AC 18 ms
6,944 KB
testcase_33 AC 11 ms
6,944 KB
testcase_34 AC 28 ms
6,940 KB
testcase_35 AC 19 ms
6,940 KB
testcase_36 AC 23 ms
6,944 KB
testcase_37 AC 18 ms
6,940 KB
testcase_38 WA -
testcase_39 AC 23 ms
6,940 KB
testcase_40 AC 21 ms
6,940 KB
testcase_41 AC 10 ms
6,940 KB
testcase_42 AC 18 ms
6,940 KB
testcase_43 AC 27 ms
6,944 KB
testcase_44 AC 22 ms
6,940 KB
testcase_45 AC 12 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

const int MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll x; cin >> x;
  ll ans = 1, d = 2, y = x;
  for (ll d = 2; d * d <= x && y > 0; d++) {
    int cnt = 0;
    while (y % d == 0) {
      y /= d;
      cnt += 1;
    }
    if (cnt % 2 == 1) ans *= d;

    ll dd = x / d;
    if (dd == d) continue;

    cnt = 0;
    while (y % dd == 0) {
      y /= dd;
      cnt += 1;
    }
    if (cnt % 2 == 1) ans *= dd;
  }
  if (x == y) {
    ans *= x;
  }
  cout << ans << endl;
}
0