查看原帖
309803
tlzhy楼主2021/7/16 23:40
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

bool zs(long long int n){
	for(int i=2;i<=sqrt(n);i++)
		if(n%i==0)return false;
 	return true;
}
int main(){
	long long int n,m,p;
	cin>>n>>m;
	for(int i=n;i<=m;i++)
	{
		for (int d1 = 1; d1 <= 9; d1+=2) {    // 只有奇数才会是素数
     		for (int d2= 0; d2 <= 9; d2++) {
         		for (int d3= 0; d3 <= 9; d3++) {
           			p = 10000*d1 + 1000*d2 +100*d3 + 10*d2 + d1;//(处理回文数...)
         		}
	 		} 
		}
		if(p==i&&zs(p)==true)cout<<p<<endl;
 	}	
	return 0;
}




2021/7/16 23:40
加载中...