Submission #1519468
Source Code Expand
#include <map> #include <set> #include <list> #include <cmath> #include <deque> #include <queue> #include <stack> #include <cstdio> #include <string> #include <vector> #include <complex> #include <cstdlib> #include <cstring> #include <numeric> #include <utility> #include <iostream> #include <algorithm> #include <functional> #include <unordered_map> #include <unordered_set> using namespace std; #define ll long long #define ull unsigned long long #define INF (1 << 29) #define LLINF (1LL << 61) #define MOD7 1000000007 #define MOD9 1000000009 #define eps 1e-9 #define P pair<int, int> #define pii pair<int, int> #define pll pair<ll, ll> #define pul pair<ull, ull> #define all(a) (a).begin(), (a).end() #define FOR(i,a,b) for (int i=(a);i<(b);++i) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i) #define REP(i,n) for (int i=0;i<(n);++i) #define RREP(i,n) for (int i=(n)-1;i>=0;--i) void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void yes() { cout << "yes" << endl; } void no() { cout << "no" << endl; } template<class T> vector<T> getPrime(T n) { T k = sqrt(n); vector<T> dst; vector<bool> used(n + 1); for (T i = 2; i <= k; ++i) { if (used[i] == false) { for (T j = i * 2; j <= n; j += i) { used[j] = true; } } } for (T i = 2; i <= n; ++i) { if (used[i] == false) { dst.push_back(i); } } return dst; } template<class T> bool isPrime(T n) { if (n == 2) return true; if (n < 2 || n % 2 == 0) return false; for (T i = 3, k = sqrt(n); i <= k; i += 2) { if (n % i == 0) return false; } return true; } int main() { int n; cin >> n; if (isPrime(n)) YES(); else NO(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 素数、コンテスト、素数 |
User | temple |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1831 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 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 | 1 ms | 256 KB |
00_sample_02.txt | AC | 1 ms | 256 KB |
00_sample_03.txt | AC | 1 ms | 256 KB |
00_sample_04.txt | AC | 1 ms | 256 KB |
01_test_01.txt | AC | 1 ms | 256 KB |
01_test_02.txt | AC | 1 ms | 256 KB |
01_test_03.txt | AC | 1 ms | 256 KB |
01_test_04.txt | AC | 1 ms | 256 KB |
01_test_05.txt | AC | 1 ms | 256 KB |
01_test_06.txt | AC | 1 ms | 256 KB |
01_test_07.txt | AC | 1 ms | 256 KB |
01_test_08.txt | AC | 1 ms | 256 KB |
01_test_09.txt | AC | 1 ms | 256 KB |
01_test_10.txt | AC | 1 ms | 256 KB |
01_test_11.txt | AC | 1 ms | 256 KB |
01_test_12.txt | AC | 1 ms | 256 KB |
01_test_13.txt | AC | 1 ms | 256 KB |
01_test_14.txt | AC | 1 ms | 256 KB |
01_test_15.txt | AC | 1 ms | 256 KB |
01_test_16.txt | AC | 1 ms | 256 KB |
01_test_17.txt | AC | 1 ms | 256 KB |
01_test_18.txt | AC | 1 ms | 256 KB |
01_test_19.txt | AC | 1 ms | 256 KB |
01_test_20.txt | AC | 1 ms | 256 KB |
01_test_21.txt | AC | 1 ms | 256 KB |
01_test_22.txt | AC | 1 ms | 256 KB |
01_test_23.txt | AC | 1 ms | 256 KB |
01_test_24.txt | AC | 1 ms | 256 KB |
01_test_25.txt | AC | 1 ms | 256 KB |