結果
| 問題 | 
                            No.300 平方数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-12-21 06:26:51 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 818 bytes | 
| コンパイル時間 | 1,717 ms | 
| コンパイル使用メモリ | 164,508 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-17 21:16:18 | 
| 合計ジャッジ時間 | 3,193 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 WA * 7 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define in(T,V) T V;cin>>V;
vector<pair<ll,int> > pdecomp(ll n){
    vector<pair<ll,int> > res;
    int e = 0; while(n % 2 == 0){ n /= 2, e++; }
    if(e) res.push_back(make_pair(2,e));
    for(ll p = 3; p*p <= n; p += 2){
        int e = 0; while(n % p == 0){ n /= p, e++; }
        if(e) res.push_back(make_pair(p,e));
    }
    if(n != 1) res.push_back(make_pair(n,1));
    return res;
}
int main(){
    in(ll,x);
    vector<pair<ll,int> > p = pdecomp(x);
    int maxv = 0;
    for(auto v : p){
        maxv = max(maxv, v.second);
    }
    if(maxv % 2) maxv++;
    ll res = 1;
    for(auto v : p){
        int n = maxv - v.second;
        REP(i,n) res *= v.first;
    }
    cout << res << endl;
}