結果

問題 No.36 素数が嫌い!
ユーザー alpha_virginisalpha_virginis
提出日時 2015-03-10 23:37:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 1,383 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 69,256 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 07:07:36
合計ジャッジ時間 2,269 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
4,376 KB
testcase_01 AC 32 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 56 ms
4,384 KB
testcase_13 AC 56 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 22 ms
4,376 KB
testcase_20 AC 55 ms
4,380 KB
testcase_21 AC 43 ms
4,376 KB
testcase_22 AC 44 ms
4,380 KB
testcase_23 AC 27 ms
4,376 KB
testcase_24 AC 11 ms
4,380 KB
testcase_25 AC 30 ms
4,376 KB
testcase_26 AC 34 ms
4,380 KB
testcase_27 AC 48 ms
4,376 KB
testcase_28 AC 33 ms
4,384 KB
testcase_29 AC 53 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <math.h>

#include <iostream>
#include <vector>
#include <list>
#include <algorithm>

int main() {

  /* default begin */
  long i, j, k;
  long n, m;
  long temp;
  long t[16] = {};
  std::vector<long> v;
  bool b;
  /* default end */

  long N;

  std::cin >> N;

  switch(N) {
  case 0:
    return 0;  
  case 1:
    std::cout << "NO" << std::endl;
    return 0;
  case 2:
    std::cout << "NO" << std::endl;
    return 0;
  case 3:
    std::cout << "NO" << std::endl;
    return 0;
  case 4:
    std::cout << "NO" << std::endl;
    return 0;
  }
  
  b = false;

  t[0] = N;
  //std::cout << t[0] << std::endl;
  for(i = 0; i < 40; i++) {
    t[0] = (t[0]/2+1) + ((N/2+1)/t[0]+1);
    //std::cout << t[0] << std::endl;
  }

  i = 2;
  for(;;) {
    if( (N % i) == 0 ) {
      v.push_back(i);
      if( v.size() >= 3 ) {
	b = true;
	goto label_1;
      }
      N /= i;
    }
    else {
      break;
    }
  }

  for(i = 3; i <= t[0]; i+=2) {
    for(;;) {
      if( (N % i) == 0 ) {
	v.push_back(i);
	if( v.size() >= 3 ) {
	  b = true;
	  goto label_1;
	}
	N /= i;
      }
      else {
	break;
      }
    }
    if( N < i ) {
      break;
    }
  }
  if( N != 1 ) {
    if( v.size() >= 2 ) {
      b = true;
    }
  }
  
 label_1:
  
  if( b ) {
    std::cout << "YES" << std::endl;
  }
  else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}

0