結果
| 問題 |
No.36 素数が嫌い!
|
| コンテスト | |
| ユーザー |
wonda_t_coffee
|
| 提出日時 | 2020-02-28 21:13:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,287 bytes |
| コンパイル時間 | 625 ms |
| コンパイル使用メモリ | 82,476 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 16:34:58 |
| 合計ジャッジ時間 | 1,976 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 WA * 2 |
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define SORT(a) sort((a).begin(), (a).end());
#define UNIQ(a) SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x) find((a).begin(), (a).end(), (x)) != (a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;
const int MOD = 1000000007; // 10^9 + 7
bool solve(ll n) {
if (n <= 4) return false;
if (n % 2 == 0) return true;
ll lim = (ll)sqrt(n);
vector<ll> primes, cnts;
for (ll d = 3; d <= lim; d += 2) {
int cnt = 0;
while (n % d == 0) {
cnt++;
n /= d;
}
if (cnt > 0) {
primes.push_back(d);
cnts.push_back(cnt);
}
}
if (n > 1) {
primes.push_back(n);
cnts.push_back(1);
}
if (primes.size() == 1 && cnts[0] <= 2) return false;
if (primes.size() == 2 && cnts[0] == 1 && cnts[1] == 1) return false;
return true;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N; cin >> N;
cout << (solve(N) ? "YES" : "NO") << endl;
}
wonda_t_coffee