0分求条
查看原帖
0分求条
1325369
SoperBoy楼主2024/8/7 11:50

样例可以过但是全WA

#include<bits/stdc++.h>
using namespace std;

bool pd(int a){
	if(a==1){
		return true;
	}
	for(int i=2;i<sqrt(a);i++){
		if(a%i==0){
			return false;
		}
	}
	return true;
}

bool pd1(int a){
	string b=to_string(a);
	string c=b;
	reverse(b.begin(),b.end());
	return b==c;
}

int main() {
	int n,cnt=0;
	cin>>n;
	for(int i=11;i<=n;i++){
		if(pd(i)&&pd1(i)){
			cnt++;
		}
	}
	cout<<cnt;
    return 0;
}
2024/8/7 11:50
加载中...