我......

null him 2020-11-05 20:57:39 2020-11-05 20:59:02 12
#include<iostream>
using namespace std;
bool zs(int x){
	if(x<2){
		return 0;
	}
	for(int i=2;i*i<=x;i++){
		if(x%i==0){
			return 0;
		}
	}
	return 1;
}
bool hws(int x){
	int s=0,x1=x;
	while(x){
		s=s*10+x%10;
		x=x/10;
	}
	if(s==x1){
		return 1;
	}
	return 0;
}
int main(){
	long long int n,m;
	cin>>n>>m;
	for(int i=n;i<=m;i++){
		if(zs(i) && hws(i)){
			cout<<i<<endl;
		}
	}
	return 0;
} 
{{ vote && vote.total.up }}

共 3 条回复

chen_zhe 沙雕

这题AC的做法(打表,特判等除外)都是

chen_zhe 沙雕

这题复杂度是假的,所谓的“正解”不是暴力卡过去就是打表或者打表出来找特殊性质(特判)

灵可以试试dfs出区间内的回文数,把它放入vector中(遍历的话会超时)然后在vector中使用线性筛(其实普通筛法也可以)

理论复杂度最大可达10^4,完全能过

null him

那位大佬帮忙看看!!!