結果

問題 No.36 素数が嫌い!
ユーザー nenuonnenuon
提出日時 2017-06-18 17:50:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 441 ms / 5,000 ms
コード長 1,126 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 89,796 KB
実行使用メモリ 54,924 KB
最終ジャッジ日時 2023-09-09 08:01:31
合計ジャッジ時間 13,601 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 318 ms
54,732 KB
testcase_01 AC 317 ms
54,672 KB
testcase_02 AC 316 ms
54,792 KB
testcase_03 AC 317 ms
54,664 KB
testcase_04 AC 319 ms
54,672 KB
testcase_05 AC 321 ms
54,692 KB
testcase_06 AC 319 ms
54,640 KB
testcase_07 AC 316 ms
54,712 KB
testcase_08 AC 317 ms
54,596 KB
testcase_09 AC 329 ms
54,668 KB
testcase_10 AC 315 ms
54,600 KB
testcase_11 AC 353 ms
54,588 KB
testcase_12 AC 435 ms
54,664 KB
testcase_13 AC 441 ms
54,676 KB
testcase_14 AC 325 ms
54,660 KB
testcase_15 AC 322 ms
54,848 KB
testcase_16 AC 323 ms
54,872 KB
testcase_17 AC 317 ms
54,592 KB
testcase_18 AC 319 ms
54,824 KB
testcase_19 AC 322 ms
54,632 KB
testcase_20 AC 323 ms
54,604 KB
testcase_21 AC 322 ms
54,732 KB
testcase_22 AC 325 ms
54,592 KB
testcase_23 AC 329 ms
54,612 KB
testcase_24 AC 338 ms
54,596 KB
testcase_25 AC 324 ms
54,600 KB
testcase_26 AC 431 ms
54,596 KB
testcase_27 AC 428 ms
54,596 KB
testcase_28 AC 428 ms
54,592 KB
testcase_29 AC 433 ms
54,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(long long I = (A); I < (B); ++I)

typedef long long ll;

map<ll, bool> MAP;
bool used[10000010];

void prime(){
    FOR(i,2,10000010){
        if(used[i]) continue;
        MAP[i] = true;
        ll j = i;
        while(j<10000010){
            used[j] = true;
            j += i;
        }
    }
}

bool isPrime(ll x){
    FOR(i,2,(ll)sqrt(x)+1)
        if(x % i == 0) return false;
    return true;
}

int main(){
    FOR(i,0,10000010) used[i] = false;
    prime();
    ll n;
    cin >> n;
    bool ok = false;
    FOR(i,2,(ll)sqrt(n)+1){
        if(n % i == 0 && MAP.count(i) == 0){
            ok = true;
            break;
        }
        if(n % i == 0 && isPrime(n / i) == 0){
            ok = true;
            break;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}
0