Yrz20140213 @ 2024-08-10 16:09:01
1,必以线性筛而为之。 2,非long long int不可。 3,若有疑问,可进言。
by IaLWH @ 2024-08-10 16:12:50
进食大佬(不是
by King_and_Grey @ 2024-08-10 16:20:53
@Yrz20140213 埃氏筛能过!
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool isPrime[100000005];
int n,q,ans[100000005],sum = 1,l;
signed main (){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin >> n >> q;
isPrime[1] = 1;
for(int i = 2;i <= n;i++){
if(isPrime[i] == 0) {
ans[sum++] = i;
for(int j = i * i;j <= n;j += i){
isPrime[j] = 1;
}
}
}
for(int i = 1;i <= q;i++){
cin >> l;
cout << ans[l] << endl;
}
return 0;
}
by amd47802574 @ 2024-08-11 13:27:24
这题不需要long long 吧
by zeng9999jian @ 2024-10-22 20:53:21
认真的?