125mb的空间?晕死
查看原帖
125mb的空间?晕死
667306
taojun6楼主2022/3/4 18:04

#include<stdio.h>
#include<string.h>
#include<stdbool.h>
int hui(int i){
 int h=0,g;
 g=i;
	while(i){
		h=h*10+i%10;
		i=i/10;
	}
	if(g==h){
		return 1;
	}
	return 0;
}
int main()
{  
   bool y[10000002];
   memset(y,1,sizeof(y));
   int a;
  int b;
   scanf("%d",&a);
   scanf("%d",&b);
   if(b>10000002){
   	b=10000002;
   }
   for(int j=2;j<=b;j++){
   	if(y[j]==1){
   		for(int k=j;k*j<=b;k++){
   			y[k*j]=0;
		   }
	   }
   }
   if(a%2==0){
   	a=a+1;
   }
   for(int i=a;i<=b;i=i+2){
   	if(y[i]&&hui(i)){
   		printf("%d\n",i);
	   }
   }
   return 0;
}
2022/3/4 18:04
加载中...