Submission #129106
Source Code Expand
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <sstream>
#include <functional>
#include <complex>
using namespace std;
#define len(array) (sizeof (array) / sizeof *(array))
#define rep(i, s, e) for(int i = s;i < e;i++)
#define Rep(i, e) for(int i = 0;i < e;i++)
#define rrep(i, e, s) for(int i = e;s <= i;i--)
#define Rrep(i, e) for(int i = e;0 <= i;i--)
#define vrange(v) v.begin(), v.end()
#define vrrange(v) v.rbegin(), v.rend()
#define vsort(v) sort(vrange(v))
#define vrsort(v) sort(vrrange(v))
#define arange(a) a, a + len(a)
#define asort(a) sort(arange(a))
#define arsort(a, t) sort(arange(a), greater<t>())
#define afill(a, v) fill(arange(a), v)
#define afill2(a, v, t) fill((t *)a, (t *)(a + len(a)), v)
#define fmax(a, b) (a < b? b : a)
#define fmin(a, b) (a > b? b : a)
#define fabs(a) (a < 0? -a : a)
#define pb push_back
#define rg(i, s, t) s <= i && i < t
//#define X real()
//#define Y imag()
//typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
//typedef complex<double> p;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
//const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
//const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//const int weight[] = {0,1,10,100,1000,10000,100000,1000000,10000000};
//priority_queue< int, vector<int>, greater<int> > q;
#define MAX_N 1000
#define MAX_PRIMES 1000002
bool bPrimes[MAX_PRIMES];
vector<int> primes;
void makePrimes(){
afill(bPrimes, true);
bPrimes[0] = bPrimes[1] = false;
rep(i, 2, MAX_PRIMES){
if(bPrimes[i]){
primes.push_back(i);
for(int j = 2*i; j < MAX_PRIMES; j += i) bPrimes[j] = false;
}
}
}
void doIt(){
int n;
makePrimes();
cin >> n;
if(bPrimes[n]) cout << "YES" << endl;
else cout << "NO" << endl;
}
int main() {
doIt();
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 素数、コンテスト、素数 |
User |
mkiken |
Language |
C++ (G++ 4.6.4) |
Score |
100 |
Code Size |
2079 Byte |
Status |
AC |
Exec Time |
38 ms |
Memory |
2468 KB |
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_01.txt |
AC |
38 ms |
2344 KB |
00_sample_02.txt |
AC |
36 ms |
2456 KB |
00_sample_03.txt |
AC |
35 ms |
2340 KB |
00_sample_04.txt |
AC |
36 ms |
2340 KB |
01_test_01.txt |
AC |
36 ms |
2460 KB |
01_test_02.txt |
AC |
36 ms |
2332 KB |
01_test_03.txt |
AC |
37 ms |
2336 KB |
01_test_04.txt |
AC |
37 ms |
2336 KB |
01_test_05.txt |
AC |
36 ms |
2396 KB |
01_test_06.txt |
AC |
36 ms |
2336 KB |
01_test_07.txt |
AC |
37 ms |
2344 KB |
01_test_08.txt |
AC |
37 ms |
2416 KB |
01_test_09.txt |
AC |
38 ms |
2332 KB |
01_test_10.txt |
AC |
36 ms |
2336 KB |
01_test_11.txt |
AC |
37 ms |
2340 KB |
01_test_12.txt |
AC |
35 ms |
2336 KB |
01_test_13.txt |
AC |
36 ms |
2340 KB |
01_test_14.txt |
AC |
36 ms |
2288 KB |
01_test_15.txt |
AC |
36 ms |
2332 KB |
01_test_16.txt |
AC |
36 ms |
2288 KB |
01_test_17.txt |
AC |
36 ms |
2468 KB |
01_test_18.txt |
AC |
36 ms |
2324 KB |
01_test_19.txt |
AC |
36 ms |
2336 KB |
01_test_20.txt |
AC |
36 ms |
2328 KB |
01_test_21.txt |
AC |
36 ms |
2328 KB |
01_test_22.txt |
AC |
36 ms |
2324 KB |
01_test_23.txt |
AC |
36 ms |
2340 KB |
01_test_24.txt |
AC |
36 ms |
2344 KB |
01_test_25.txt |
AC |
36 ms |
2336 KB |