Gojo_Satoru2023 @ 2024-06-15 17:16:02
WA代码:
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e8;
int n , m ;
int mark[N] , p[N] , cnt ;
void prime(){
for(int i = 2 ; i <= n ; i ++){
if(!mark[i]){
p[++cnt] = i ;
}
for(int j = 1 ; p[j] * i <= n ; j ++){
mark[i * p[j]] = 1 ;
if(i % p[j] == 0) {
break ;
}
}
}
}
int main(){
cin >> n >> m ;
prime();
for(int i = 1 ; i <= m ; i ++){
int x ;
cin >> x ;
cout << p[x] << "\n";
continue ;
}
return 0 ;
}
AC代码:
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e8;
int n , m ;
int p[N] , mark[N] , cnt ;
void prime(){
for(int i = 2 ; i <= n ; i ++){
if(!mark[i]){
p[++cnt] = i ;
}
for(int j = 1 ; p[j] * i <= n ; j ++){
mark[i * p[j]] = 1 ;
if(i % p[j] == 0) {
break ;
}
}
}
}
int main(){
cin >> n >> m ;
prime();
for(int i = 1 ; i <= m ; i ++){
int x ;
cin >> x ;
cout << p[x] << "\n";
continue ;
}
return 0 ;
}
by Ctrl_sku @ 2024-07-31 16:19:38
@Gojo_Satoru2023 fvv代码写成这样你是怎么敢发博客的
by Gojo_Satoru2023 @ 2024-07-31 16:29:46
@Ctrl_sku 傻叉别喷
by Ctrl_sku @ 2024-07-31 17:59:02
@Gojo_Satoru2023 服了sb , qzb不来集训上什么洛谷,我电影院
by Gojo_Satoru2023 @ 2024-07-31 18:31:17
@Ctrl_sku 你是谁
by Gojo_Satoru2023 @ 2024-07-31 18:32:05
@Ctrl_sku 曾钰航是吧
by Ctrl_sku @ 2024-08-01 09:56:47
@Gojo_Satoru2023 我西你?