最后TLE怎么办???
查看原帖
最后TLE怎么办???
806193
caijueyu楼主2023/4/23 17:10
#include<bits/stdc++.h>
using namespace std;
int a, b;
int fan(int x) {
	int y = 0 ;
	while(x != 0) {
		y = y * 10 + x % 10;
		x = x / 10;
	}
	return y;
}
bool calc(int x) {
	int y = fan(x);
	if(x < 2 || y < 2 || y != x)	
		return false;
	for(int i = 2; i <= sqrt(y); i++) {
		if(x % i == 0 && y % i == 0)
			return false;
	}
	return true;
}
int main(){
	scanf("%d%d", &a, &b);
	for(int i = a; i <= b; i++){
		if(calc(i))
			printf("%d\n", i);
	}
}
2023/4/23 17:10
加载中...