結果

問題 No.36 素数が嫌い!
ユーザー dazydazy
提出日時 2017-11-29 21:46:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 76 ms / 5,000 ms
コード長 778 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 60,124 KB
実行使用メモリ 12,992 KB
最終ジャッジ日時 2023-09-09 08:09:25
合計ジャッジ時間 2,150 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,788 KB
testcase_01 AC 41 ms
10,752 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 25 ms
6,488 KB
testcase_12 AC 76 ms
12,796 KB
testcase_13 AC 76 ms
12,992 KB
testcase_14 AC 31 ms
9,208 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 8 ms
7,024 KB
testcase_20 AC 54 ms
12,764 KB
testcase_21 AC 11 ms
10,752 KB
testcase_22 AC 16 ms
10,784 KB
testcase_23 AC 16 ms
7,932 KB
testcase_24 AC 32 ms
8,368 KB
testcase_25 AC 6 ms
8,280 KB
testcase_26 AC 46 ms
9,064 KB
testcase_27 AC 66 ms
11,528 KB
testcase_28 AC 47 ms
9,020 KB
testcase_29 AC 76 ms
12,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <math.h>
using namespace std;

#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define scan(x) cin >> x
#define print(x) cout << x << "\n"


int main() {
    fastcin;
    long N; scan(N);
    auto sq = (int)sqrt(N);
    bool flag = false, p[sq+1];
    int k;
    rep(i, 2, sq+1) p[i] = true;
    rep(i, 2, sq+1) {
        if (p[i]) {
            k = i;
            while (k!=N && !(N%k)) {
                if (flag) {
                    print("YES");
                    return 0;
                }
                flag = true;
                k *= k;
            }
            for (int j = i<<1; j < sq+1; j+=i) p[j] = false;
        }
    }
    print("NO");
    return 0;
}
0