結果

問題 No.300 平方数
ユーザー face4
提出日時 2018-05-05 08:43:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 399 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 67,584 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 01:31:33
合計ジャッジ時間 1,873 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
using namespace std;

typedef long long ll;

int main(){
    ll x;
    cin >> x;
    ll ans = 1;
   
    for(ll i = 2; i*i <= x; i++){
        ll cnt = 0;
        while(x%i == 0){
            x /= i;
            cnt++;
        }

        if(cnt%2 == 1){
            ans *= i;
        }
    }

    if(x > 1)   ans *= x;
    
    cout << ans << endl;
    return 0;
}
0