結果

問題 No.36 素数が嫌い!
ユーザー dazydazy
提出日時 2017-11-29 21:43:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 769 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 59,260 KB
実行使用メモリ 12,856 KB
最終ジャッジ日時 2023-08-18 13:47:45
合計ジャッジ時間 2,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,996 KB
testcase_01 AC 50 ms
10,700 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 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,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 25 ms
6,432 KB
testcase_12 AC 91 ms
12,856 KB
testcase_13 AC 91 ms
12,828 KB
testcase_14 AC 32 ms
9,268 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 8 ms
7,012 KB
testcase_20 AC 71 ms
12,776 KB
testcase_21 AC 12 ms
10,756 KB
testcase_22 AC 17 ms
10,756 KB
testcase_23 AC 17 ms
7,792 KB
testcase_24 AC 34 ms
8,392 KB
testcase_25 AC 6 ms
8,424 KB
testcase_26 AC 48 ms
9,076 KB
testcase_27 AC 77 ms
11,444 KB
testcase_28 AC 46 ms
8,936 KB
testcase_29 AC 89 ms
12,472 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 (!(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