Submission #00018


ソースコード

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
#include<bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define lb(v,a) lower_bound(v.begin(),v.end(),a)
#define ub(v,a) upper_bound(v.begin(),v.end(),a)
#define bs(v,a) binary_search(v.begin(),v.end(),a)
#define bitcount(i) __builtin_popcount(i)
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
vector<bool> p(1e7,false);
for(int i = 2;i <= 6000000;i++){
if(p[i] == false){
for(int j = 2;j*i <= 6000000;j++){
p[i*j] = true;
}
}
}
while(n--){
int a;
cin>>a;
if(a == 1){
cout<<2<<"\n";
}else if(p[a] == true){
cout<<"NA\n";
}else{
cout<<"1\n";
}
}
return(0);
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 53 ms 1756 KB
1
in02.txt AC 46 ms 1632 KB
1
in03.txt AC 103 ms 1636 KB
1
in04.txt AC 56 ms 1764 KB
1
in05.txt AC 51 ms 1640 KB
1
in06.txt AC 60 ms 2292 KB
1
in07.txt AC 125 ms 5108 KB
1
in08.txt AC 117 ms 7412 KB
1
in09.txt AC 119 ms 9844 KB
1
in10.txt AC 122 ms 12664 KB
1
in11.txt AC 120 ms 15480 KB
1
in12.txt AC 140 ms 18428 KB
1
in13.txt AC 127 ms 21248 KB
1
in14.txt AC 127 ms 24196 KB
1
in15.txt AC 130 ms 27016 KB
1
in16.txt AC 82 ms 27788 KB
1
in17.txt AC 126 ms 29580 KB
1
in18.txt AC 122 ms 31628 KB
1
in19.txt AC 124 ms 33548 KB
1
in20.txt AC 135 ms 36496 KB
1
in21.txt AC 149 ms 38420 KB
1
in22.txt AC 97 ms 40344 KB
1
in23.txt AC 119 ms 42528 KB
1
in24.txt AC 52 ms 42528 KB
1
in25.txt AC 55 ms 42544 KB
1
in26.txt AC 49 ms 42552 KB
1
sample01.txt AC 55 ms 42568 KB
1