(需要些快读吗)求救TLE啊啊啊啊
查看原帖
(需要些快读吗)求救TLE啊啊啊啊
278371
Programmer_juruo楼主2020/11/9 19:50
/*
problem:
created:Programmer_juruo

BE CAREFUL:
1.read the text carefully
2.is it TLE?
3.if something is 0 or 1, is it be very special?
4.is it MLE?

WISH YOU AC!!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef double db;
typedef long double ldb;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define y1 _y1
#define int long long
const int inf = 0x3f3f3f3f;
const ll ll_inf = 0x3f3f3f3f3f3f3f3fll;
const ldb eps = 1e-8;
const ldb pi = acos(-1);
const int N = 1e8 + 1000;
const int M = 6e7 + 100;
int n, k;
int a[M];
bool p[N];
int cnt;
void Get_Pr() {
	for(int i = 2; i <= n; i++) p[i] = 1;
	for(int i = 2; i <= n; i++) {
		if(p[i]) {
			a[cnt++] = i;
		}
		for(int j = 0; j < cnt && i * a[j] <= n; j++) {
			int v = i * a[j];
			p[v] = 0;
			if(i % a[j] == 0) break; 
		}
	}
}
void init() {
	Get_Pr();
}
void read() {
	scanf("%d", &k);
}
void solve() {
}
void write() {
	cout << a[k-1] << endl;
}
signed main() {
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
	int T = 1;
	cin >> n >> T;
	while(T--) {
	    init();
		read();
		solve();
		write();
	}
	return 0;
	
}


2020/11/9 19:50
加载中...