样例没过呜呜呜
查看原帖
样例没过呜呜呜
1638306
CYM2025tobe1楼主2025/1/16 19:56

以下是代码:

#include<iostream>
using namespace std;
bool pr(int i){
	for(int j=2;j<=i;i++){
		if(i%j==0){
			return false;
		}
	}
  return true;
}
bool pa(int i){
	int x=0,s=i;
	while(s>0){
		x=x*10+s%10;   
		s=s/10;        
	}
    if(x==i){  
    	return true;
		}
    else{
        return false;
        }
}
int main(){
	int n,m=0;    
	cin>>n;
	for(int i=11;i<=n;i++){
		if(pr(i)&&pa(i)){
			m++;
		}
	}
	cout<<m;
	return 0;
}
2025/1/16 19:56
加载中...