結果

問題 No.36 素数が嫌い!
ユーザー DialBirdDialBird
提出日時 2016-11-28 19:48:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 549 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 58,968 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 14:40:11
合計ジャッジ時間 1,186 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 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 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

#define REP(i,first,last) for(int i=first;i<last;i++)

bool check(int n){
  int origin_n = n;
  int i = 2;
  int count = 0;
  while (n != 1 && i <= sqrt(origin_n)) {
    if (n % i == 0) {
      count++;
      if (count == 3) return true;
      n /= i;
    } else {
      i++;
    }
  }
  if (n != 1 && count == 2) {
    return true;
  } else {
    return false;
  }
}

int main(){
  int n;
  cin >> n;
  if (check(n)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
0