結果

問題 No.36 素数が嫌い!
ユーザー imulanimulan
提出日時 2016-05-19 22:34:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 201 ms / 5,000 ms
コード長 997 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 144,956 KB
実行使用メモリ 13,368 KB
最終ジャッジ日時 2023-09-09 07:37:24
合計ジャッジ時間 6,332 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
13,188 KB
testcase_01 AC 102 ms
13,100 KB
testcase_02 AC 98 ms
13,108 KB
testcase_03 AC 99 ms
13,108 KB
testcase_04 AC 99 ms
13,096 KB
testcase_05 AC 101 ms
13,084 KB
testcase_06 AC 101 ms
13,152 KB
testcase_07 AC 101 ms
13,316 KB
testcase_08 AC 98 ms
13,156 KB
testcase_09 AC 104 ms
13,112 KB
testcase_10 AC 101 ms
13,108 KB
testcase_11 AC 134 ms
13,104 KB
testcase_12 AC 201 ms
13,080 KB
testcase_13 AC 198 ms
13,112 KB
testcase_14 AC 101 ms
13,172 KB
testcase_15 AC 101 ms
13,368 KB
testcase_16 AC 100 ms
13,244 KB
testcase_17 AC 100 ms
13,184 KB
testcase_18 AC 101 ms
13,144 KB
testcase_19 AC 100 ms
13,096 KB
testcase_20 AC 104 ms
13,160 KB
testcase_21 AC 100 ms
13,216 KB
testcase_22 AC 99 ms
13,144 KB
testcase_23 AC 97 ms
13,172 KB
testcase_24 AC 114 ms
13,276 KB
testcase_25 AC 99 ms
13,108 KB
testcase_26 AC 200 ms
13,312 KB
testcase_27 AC 186 ms
13,096 KB
testcase_28 AC 195 ms
13,076 KB
testcase_29 AC 193 ms
13,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N=10000000;
bool p[N+1];

bool inline prime(ll x)
{
    for(ll i=2; i*i<=x; ++i)
    {
        if(x%i==0) return false;
    }
    return true;
}

bool valid(ll x)
{
    fill(p,p+N+1,true);
    p[0]=p[1]=false;
    for(ll i=2; i<=N; ++i)
    {
        if(p[i]) for(ll j=2; i*j<=N; ++j) p[i*j]=false;
    }


    for(ll i=2; i*i<=x; ++i)
    {
        if(x%i==0)
        {
            if(!p[i]) return true;
            else
            {
                if(!prime(x/i)) return true;
            }
        }
    }

    return false;
}

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

    string ans="NO";
    if(valid(n)) ans="YES";

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