結果

問題 No.36 素数が嫌い!
ユーザー wonda_t_coffeewonda_t_coffee
提出日時 2020-02-28 21:03:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,272 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 83,560 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 17:42:58
合計ジャッジ時間 2,285 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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<int> 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);
    }
  }
  primes.push_back(n);
  cnts.push_back(1);
  if (primes.size() == 1 && cnts.size() <= 2) return false;
  if (primes.size() == 2 && primes[0] == 1 && primes[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;
}
0