大佬们,超时
查看原帖
大佬们,超时
1114929
vckk418楼主2023/12/18 20:43
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int ss(long n){
	if(n==1){
		return -1;
	}else{
		for(long i=2;i<=sqrt(n);i++){
			if(n%i==0){
				return -1;
			}
		}
		return 1;
	}
}
int main(){
	long a,b,i,j,q;
	char s[20];
	int count=1;
	scanf("%ld%ld",&a,&b);
	for(i=a;i<=b;i++){
		count=1;
		if(ss(i)==1){
			sprintf(s,"%ld",i);
			for(j=0;j<strlen(s)/2;j++){
				if(s[j]!=s[strlen(s)-1-j]){
					count=0;
					break;
				}
			}
			if(count==1){
				printf("%ld\n",i);
			}
		}
	}

	return 0;
}
2023/12/18 20:43
加载中...