超时求助
查看原帖
超时求助
758565
czj20091123楼主2022/11/16 21:40
#include<bits/stdc++.h>
using namespace std;
bool zhi(int a){
	
	if(a>1){
		int k=a/2+1;
		while(a%k!=0){
			k--;
		}
		if(k==1){
			return 1;
		}else{
			return 0;
		}
	}else{
		return 0;
	}
}
bool huiwen(int k){
	int k1=k;
	int k2=0;
	int s=k;
	while(s!=0){
		k2=k2*10+s%10;
		s/=10;
	}
	if(k1==k2){
		return 1;
	}else{
		return 0;
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=n;i<=m;i++){
		if(huiwen(i)==1&&zhi(i)==1){
			printf("%d\n",i);
		}
	} 
	return 0;
} 
2022/11/16 21:40
加载中...