結果

問題 No.36 素数が嫌い!
ユーザー motimoti
提出日時 2015-12-31 18:57:07
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,673 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 105,320 KB
実行使用メモリ 16,484 KB
最終ジャッジ日時 2023-10-19 12:53:55
合計ジャッジ時間 6,686 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

void ng() {cout << "NO\n";exit(0);}
void ok() {cout << "YES\n"; exit(0);}

namespace math {
namespace prime {

constexpr int Max = 1e7+1;    // !!!INPUT MAX NUMBER!!!

int prime[Max];
bool is_prime[Max];

int sieve(int n) {
  int prime_count = 0;
  rep(i, n+1) is_prime[i] = 1;
  is_prime[0] = is_prime[1] = 0;
  REP(i, 2, n+1) {
    if(!is_prime[i]) { continue; }
    prime[prime_count++] = i;
    for(long long j=(long long)i*i; j<=n; j+=i) {
      is_prime[j] = 0;
    }
  }
  return prime_count;
}

}
#define USE_PRIME_SIEVE \
  using math::prime::prime; \
  using math::prime::is_prime;  \
  using math::prime::sieve;
}

USE_PRIME_SIEVE

int main() {

  ll N; cin >> N;
  sieve(sqrt(N+1));

  set<ll> st;
  for(int i=2; (ll)i*i<=N; i++) {
    if(is_prime[i] && N % i == 0 && !is_prime[N/i]) {
      ok();
    }
  }

  ng();

  return 0;
}
0