Submission #00112


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n,i,j;
vector<bool> tf(6000001,true);
tf[0]=false;
tf[1]=false;
for(i=4;i<=6000000;i+=2){
tf[i]=false;
}
for(i=3;i*i<=6000000;i+=2){
if(tf[i]){
for(j=3;j*i<=6000000;j++){
tf[i*j]=false;
}
}
}
cin>>n;
int a[n];
for(i=0;i<n;i++){
cin>>a[i];
}
for(i=0;i<n;i++){
if(a[i]==1){
cout<<"2\n";
}else if(tf[a[i]]){
cout<<"1\n";
}else{
cout<<"NA\n";
}
}
return(0);
}

ステータス

項目 データ
問題 0009 - 掛けても素数!?
ユーザー名 ei2229
投稿日時 2023-07-18 17:26:51
言語 C++17
状態 Accepted
得点 100
ソースコード長 711 Byte
最大実行時間 129 ms
最大メモリ使用量 45932 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 46 ms 1372 KB
1
in02.txt AC 34 ms 1228 KB
1
in03.txt AC 45 ms 1336 KB
1
in04.txt AC 36 ms 1320 KB
1
in05.txt AC 31 ms 1172 KB
1
in06.txt AC 50 ms 2436 KB
1
in07.txt AC 119 ms 8476 KB
1
in08.txt AC 101 ms 10252 KB
1
in09.txt AC 104 ms 12432 KB
1
in10.txt AC 108 ms 15872 KB
1
in11.txt AC 116 ms 18996 KB
1
in12.txt AC 113 ms 21856 KB
1
in13.txt AC 106 ms 24720 KB
1
in14.txt AC 117 ms 27584 KB
1
in15.txt AC 120 ms 30448 KB
1
in16.txt AC 60 ms 28960 KB
1
in17.txt AC 106 ms 33096 KB
1
in18.txt AC 120 ms 35192 KB
1
in19.txt AC 104 ms 37036 KB
1
in20.txt AC 129 ms 40160 KB
1
in21.txt AC 81 ms 42000 KB
1
in22.txt AC 83 ms 43964 KB
1
in23.txt AC 101 ms 45932 KB
1
in24.txt AC 36 ms 42140 KB
1
in25.txt AC 42 ms 42124 KB
1
in26.txt AC 36 ms 41980 KB
1
sample01.txt AC 34 ms 41972 KB
1