結果
| 問題 | 
                            No.300 平方数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             wonda_t_coffee
                         | 
                    
| 提出日時 | 2020-02-27 23:53:15 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 876 bytes | 
| コンパイル時間 | 658 ms | 
| コンパイル使用メモリ | 79,612 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-13 16:05:04 | 
| 合計ジャッジ時間 | 3,003 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 33 WA * 10 | 
ソースコード
#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;
  }
  cout << ans << endl;
}
            
            
            
        
            
wonda_t_coffee