Submission #00103


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool memo[6000010];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
scanf("%d", &n);
for(int i = 2;i <= 6000000;i++){
if(!memo[i]){
for(int j = i*2;j <= 6000000;j+=i){
memo[j] = true;
}
}
}
int a;
while(n--){
scanf("%d", &a);
if(a == 1){
printf("%d\n", 2);
}else if(!memo[a]){
printf("%d\n", 1);
}else{
printf("NA\n");
}
}
return 0;
}

ステータス

項目 データ
問題 0005 - 掛けても素数!?
ユーザー名 ei1719
投稿日時 2020-04-25 22:26:21
言語 C++14
状態 Accepted
得点 300
ソースコード長 659 Byte
最大実行時間 219 ms
最大メモリ使用量 47032 KB

セット

セット 得点 Cases
1 ALL 300 / 300 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 46 ms 6492 KB
1
in02.txt AC 54 ms 6472 KB
1
in03.txt AC 54 ms 6444 KB
1
in04.txt AC 54 ms 6416 KB
1
in05.txt AC 49 ms 6392 KB
1
in06.txt AC 71 ms 6880 KB
1
in07.txt AC 131 ms 9804 KB
1
in08.txt AC 112 ms 12212 KB
1
in09.txt AC 131 ms 14364 KB
1
in10.txt AC 136 ms 17284 KB
1
in11.txt AC 134 ms 20208 KB
1
in12.txt AC 171 ms 23000 KB
1
in13.txt AC 142 ms 25920 KB
1
in14.txt AC 151 ms 28836 KB
1
in15.txt AC 154 ms 31628 KB
1
in16.txt AC 99 ms 32492 KB
1
in17.txt AC 219 ms 34380 KB
1
in18.txt AC 177 ms 36536 KB
1
in19.txt AC 177 ms 38304 KB
1
in20.txt AC 124 ms 41220 KB
1
in21.txt AC 151 ms 43116 KB
1
in22.txt AC 151 ms 45136 KB
1
in23.txt AC 180 ms 47032 KB
1
in24.txt AC 47 ms 47004 KB
1
in25.txt AC 52 ms 46976 KB
1
in26.txt AC 50 ms 46952 KB
1
sample01.txt AC 56 ms 46928 KB
1