結果

問題 No.36 素数が嫌い!
ユーザー ManjushriMitra
提出日時 2024-07-27 11:41:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 105 ms / 5,000 ms
コード長 1,081 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 174,676 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-27 11:41:48
合計ジャッジ時間 3,803 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(int i=m; i<n; ++i)
#define repl(i,m,n) for(ll i=m; i<n; ++i)

int main(){
    ll N;
    cin >> N;

    map<ll, ll> prime_fact;
    for(ll i = 2; i*i <= N; ++i){
        if(N % i != 0LL) continue;
        ll ex = 0LL;
        while(N % i == 0){
            N /= i;
            ex++;
        }
        prime_fact[i] = ex;
    }
    if(N != 1LL) prime_fact[N] = 1LL;

    // for(auto &p : prime_fact) cout << p.first << ' ' << p.second << endl;

    if(prime_fact.size() > 2){
        cout << "YES" << endl;
        return 0;
    }else if(prime_fact.size() == 2){
        for(auto &p : prime_fact){
            if(p.second > 1LL){
                cout << "YES" << endl;
                return 0;
            }
        }
        cout << "NO" << endl;
        return 0;
    }else{
        for(auto &p : prime_fact){
            if(p.second > 2LL){
                cout << "YES" << endl;
                return 0;
            }
        }
        cout << "NO" << endl;
        return 0;    
    }
}
0