結果

問題 No.36 素数が嫌い!
ユーザー imulanimulan
提出日時 2016-05-19 22:32:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 997 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 159,076 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-04-16 01:40:49
合計ジャッジ時間 5,985 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
12,928 KB
testcase_01 WA -
testcase_02 AC 105 ms
13,056 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 103 ms
12,928 KB
testcase_08 AC 104 ms
13,056 KB
testcase_09 AC 102 ms
13,184 KB
testcase_10 AC 102 ms
12,928 KB
testcase_11 AC 135 ms
13,184 KB
testcase_12 AC 204 ms
13,184 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 105 ms
13,056 KB
testcase_17 AC 106 ms
13,184 KB
testcase_18 AC 105 ms
13,056 KB
testcase_19 AC 106 ms
13,184 KB
testcase_20 AC 114 ms
13,184 KB
testcase_21 AC 102 ms
13,184 KB
testcase_22 AC 104 ms
13,184 KB
testcase_23 AC 104 ms
13,184 KB
testcase_24 WA -
testcase_25 AC 105 ms
13,056 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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 true;
    }
    return false;
}

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