結果

問題 No.36 素数が嫌い!
ユーザー kaffelunkaffelun
提出日時 2017-11-09 22:19:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 147,312 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 22:27:21
合計ジャッジ時間 2,480 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 WA -
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 5 ms
4,380 KB
testcase_29 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool solve(int64_t N) {
	vector<int64_t> v;
    int64_t c = 1;
    int64_t limit = (int64_t)sqrt(N);
    int f = 0;
    while (c < limit) {
        c++;
        bool flag = true;
        int64_t d = (int)sqrt(c);
        for(int i = 0; i < v.size(); i++) {
        	if(c % v[i] == 0) {
        		flag = false;
        		break;
        	}
        	if (d < v[i]) break;
        }
        if(flag) {
        	v.push_back(c);
        	int64_t tmp = N;
        	while(tmp % c == 0) {
        		f++;
        		tmp /= c;
        	}
        	if(f >= 2) return true;
        }
    }
    return false;
}

int main() {
	int N;
	cin >> N;
	cout << (solve(N) ? "YES" : "NO") << endl;
	return 0;
}
0