結果

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

テストケース

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

ソースコード

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 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(!p[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