結果

問題 No.36 素数が嫌い!
ユーザー naimonon77naimonon77
提出日時 2015-10-14 21:19:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,004 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 67,224 KB
実行使用メモリ 6,232 KB
最終ジャッジ日時 2023-09-28 21:02:50
合計ジャッジ時間 85,553 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2,683 ms
5,944 KB
testcase_03 AC 2,683 ms
6,212 KB
testcase_04 AC 2,681 ms
5,884 KB
testcase_05 AC 2,682 ms
5,940 KB
testcase_06 AC 2,682 ms
6,052 KB
testcase_07 AC 2,678 ms
6,000 KB
testcase_08 AC 2,692 ms
5,880 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2,683 ms
5,952 KB
testcase_12 AC 2,680 ms
6,004 KB
testcase_13 AC 2,686 ms
6,224 KB
testcase_14 WA -
testcase_15 AC 2,684 ms
5,948 KB
testcase_16 AC 2,680 ms
6,020 KB
testcase_17 AC 2,678 ms
5,884 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2,680 ms
5,928 KB
testcase_27 AC 2,680 ms
6,060 KB
testcase_28 AC 2,683 ms
5,872 KB
testcase_29 AC 2,679 ms
5,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
using namespace std;


#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef long double lb;
/* ここからが本編 */

/* prime_rekkyo(prime,n)は
 n以下の素数をまで2,3,…と格納していきます */
void prime_rekkyo(int prime[],int n)
{
   int i,j,k;
   int a = 0;
   prime[a++] = 2;

   for(i=3;i<=n;i+=2)
   {
      k=0;
      for(j=3;j*j<=i;j+=2)
      {
         if(i%j==0)
         {
            k=1;
            break;
         }
      }

      if(k==0) prime[a++] = i;
   }
}

int main(void)
{
   ull i=1,j,k;
   ull n;
   cin >> n;
   char cnt = 0;

   static int e[1000000];
   prime_rekkyo(e,10000005);
   for(j=0;e[j]*e[j] <= n;j++)
   {
      if(n % e[j] == 0) cnt++;
   }
   if(cnt > 2) cout << "YES" << endl;
   else cout << "NO" << endl;

   return 0;
}
0