結果

問題 No.36 素数が嫌い!
ユーザー ronnyaronnya
提出日時 2022-05-16 06:49:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 5,000 ms
コード長 1,005 bytes
コンパイル時間 2,488 ms
コンパイル使用メモリ 206,028 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 22:00:05
合計ジャッジ時間 5,453 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
4,348 KB
testcase_01 AC 83 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 35 ms
4,348 KB
testcase_12 AC 103 ms
4,352 KB
testcase_13 AC 103 ms
4,352 KB
testcase_14 AC 65 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,352 KB
testcase_19 AC 48 ms
4,352 KB
testcase_20 AC 110 ms
4,352 KB
testcase_21 AC 97 ms
4,348 KB
testcase_22 AC 85 ms
4,348 KB
testcase_23 AC 51 ms
4,348 KB
testcase_24 AC 69 ms
4,348 KB
testcase_25 AC 73 ms
4,352 KB
testcase_26 AC 98 ms
4,348 KB
testcase_27 AC 90 ms
4,356 KB
testcase_28 AC 96 ms
4,348 KB
testcase_29 AC 100 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
#define irep(i, v) for(auto i = (v).begin(); i != (v).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()

const ll INF = 1e18;
const ld EPS = 1e-10;

bool is_prime(ll n){
  if(n <= 1) return false;
  bool res = 1;
  for(ll i = 2; i * i <= n; i++){
    res = res && !(n % i == 0);
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  cout << fixed << setprecision(20);


  ll n;
  cin >> n;
  vector<ll> fac;
  for(ll i = 1; i * i <= n; i++){
    if(n % i == 0){
      fac.push_back(i);
      if(i * i != n) fac.push_back(n / i);
    }
  }
  sort(ALL(fac));

  bool f = 0;
  rep(i, 0, SZ(fac)){
    ll m = fac[i];
    if(m == 1 || m == n || is_prime(m)) continue;
    if(n % m == 0) f = 1;
  }
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;




  return 0;
}
0