Submission #00046
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #include <bits/stdc++.h> #define F first #define S second #define MP make_pair #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define LCM(a, b) (a) / __gcd((a), (b)) * (b) #define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0) #define ln '\n' using namespace std; using LL = long long ; using ldouble = long double ; using P = pair< int , int >; using LP = pair<LL, LL>; static const int INF = INT_MAX; static const LL LINF = LLONG_MAX; static const int MIN = INT_MIN; static const LL LMIN = LLONG_MIN; static const int MOD = 1e9 + 7; static const int SIZE = 200005; const int dx[] = {0, -1, 1, 0}; const int dy[] = {-1, 0, 0, 1}; vector<LL> Div(LL n) { vector<LL> ret; for (LL i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.pb(i); if (i * i != n) ret.pb(n / i); } } sort(all(ret)); return ret; } bool prime[6000006]; int main() { ios::sync_with_stdio( false ); cin.tie(0); int n; cin >> n; for ( int i = 0; i < 6000006; ++i) prime[i] = true ; prime[1] = false ; for ( int i = 2; i < 6000006; ++i) { if (prime[i]) { for ( int j = i * 2; j < 6000006; j += i) prime[j] = false ; } } while (n--) { int a; cin >> a; if (prime[a]) cout << 1; else if (a == 1) cout << 2; else cout << "NA" ; cout << ln; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0005 - 掛けても素数!? |
ユーザー名 | crom |
投稿日時 | 2020-04-25 21:29:39 |
言語 | C++14 |
状態 | Accepted |
得点 | 300 |
ソースコード長 | 1482 Byte |
最大実行時間 | 196 ms |
最大メモリ使用量 | 47100 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 300 / 300 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 50 ms | 6364 KB |
1
|
in02.txt | AC | 54 ms | 6472 KB |
1
|
in03.txt | AC | 59 ms | 6448 KB |
1
|
in04.txt | AC | 52 ms | 6420 KB |
1
|
in05.txt | AC | 58 ms | 6520 KB |
1
|
in06.txt | AC | 68 ms | 6884 KB |
1
|
in07.txt | AC | 166 ms | 9804 KB |
1
|
in08.txt | AC | 156 ms | 12080 KB |
1
|
in09.txt | AC | 134 ms | 14488 KB |
1
|
in10.txt | AC | 178 ms | 17412 KB |
1
|
in11.txt | AC | 165 ms | 20076 KB |
1
|
in12.txt | AC | 144 ms | 23000 KB |
1
|
in13.txt | AC | 163 ms | 25792 KB |
1
|
in14.txt | AC | 196 ms | 28708 KB |
1
|
in15.txt | AC | 181 ms | 31628 KB |
1
|
in16.txt | AC | 105 ms | 32372 KB |
1
|
in17.txt | AC | 157 ms | 34396 KB |
1
|
in18.txt | AC | 155 ms | 36420 KB |
1
|
in19.txt | AC | 169 ms | 38320 KB |
1
|
in20.txt | AC | 140 ms | 41232 KB |
1
|
in21.txt | AC | 123 ms | 43256 KB |
1
|
in22.txt | AC | 125 ms | 45152 KB |
1
|
in23.txt | AC | 138 ms | 47048 KB |
1
|
in24.txt | AC | 53 ms | 46896 KB |
1
|
in25.txt | AC | 47 ms | 47008 KB |
1
|
in26.txt | AC | 51 ms | 46988 KB |
1
|
sample01.txt | AC | 47 ms | 47100 KB |
1
|