結果

問題 No.36 素数が嫌い!
ユーザー kpinkcatkpinkcat
提出日時 2023-10-09 03:59:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 393 ms / 5,000 ms
コード長 860 bytes
コンパイル時間 1,171 ms
コンパイル使用メモリ 105,276 KB
実行使用メモリ 81,364 KB
最終ジャッジ日時 2023-10-09 03:59:44
合計ジャッジ時間 6,771 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
81,112 KB
testcase_01 AC 129 ms
80,996 KB
testcase_02 AC 84 ms
81,364 KB
testcase_03 AC 84 ms
81,172 KB
testcase_04 AC 85 ms
81,180 KB
testcase_05 AC 85 ms
81,112 KB
testcase_06 AC 304 ms
81,000 KB
testcase_07 AC 389 ms
80,988 KB
testcase_08 AC 31 ms
81,116 KB
testcase_09 AC 31 ms
81,312 KB
testcase_10 AC 39 ms
81,108 KB
testcase_11 AC 362 ms
81,116 KB
testcase_12 AC 367 ms
81,004 KB
testcase_13 AC 393 ms
80,996 KB
testcase_14 AC 284 ms
80,996 KB
testcase_15 AC 31 ms
81,308 KB
testcase_16 AC 84 ms
81,244 KB
testcase_17 AC 362 ms
81,100 KB
testcase_18 AC 31 ms
81,108 KB
testcase_19 AC 31 ms
81,052 KB
testcase_20 AC 40 ms
81,060 KB
testcase_21 AC 32 ms
81,120 KB
testcase_22 AC 115 ms
81,172 KB
testcase_23 AC 74 ms
81,308 KB
testcase_24 AC 73 ms
81,116 KB
testcase_25 AC 39 ms
80,992 KB
testcase_26 AC 81 ms
81,340 KB
testcase_27 AC 253 ms
81,088 KB
testcase_28 AC 82 ms
81,092 KB
testcase_29 AC 312 ms
81,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main(){
    ll n, tmp, cnt = 0;
    cin >> n;
    tmp = 10000000;
    vector<ll> prime(tmp, 1);
    vector<ll> fac;
    prime[0] = 0;
    for (int i = 2; i <= tmp; i++){
        if (prime[i]){
            if (!fac.size()){
                for (int j = i+i; j < tmp; j += i){
                    prime[j] = 0;
                }
            }
            if (!(n%i)){
                cnt++;
                fac.push_back(i);
                n /= i;
                i--;
            }
            if (cnt >= 2 && n != 1){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}
0