結果

問題 No.300 平方数
ユーザー face4
提出日時 2018-05-05 08:37:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 747 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 68,004 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 01:31:27
合計ジャッジ時間 2,103 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;

int main(){
    ll x;
    cin >> x;
    ll ans = 1;
    
    while(1){
        if(x%2 == 0){
            x /= 2;
            if(x%2 == 0){
                x /= 2;
            }else{
                ans *= 2;
                break;
            }
        }else{
            break;
        }
    }

    ll divisor = 3;
    ll ceil = sqrt(x);
    
    while(divisor <= ceil){
        if(x%divisor == 0){
            x /= divisor;
            if(x%divisor == 0){
                x /= divisor;
            }else{
                ans *= divisor;                
            }
        }else{
            divisor += 2;
        }
    }

    cout << ans << endl;
    return 0;
}
0