44分help!
查看原帖
44分help!
373515
xuyunchuan楼主2021/3/12 19:42

代码如下: 除了1/2/5/6其他测试点都是TLE(开了O2)

#include<bits/stdc++.h>
using namespace std;
int c[10];
int main(){
	long long a,b;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		bool flag=true;
		for(int j=2;j<=sqrt(i);j++) if(i%j==0) flag=false;
		int x=i,sum=0;
		while(x!=0){
			sum++;
			c[sum]=x%10;
			x/=10;
		}
		for(int j=1;j<=sum/2;j++) if(c[j]!=c[sum+1-j]) flag=false;
		if(flag) cout<<i<<endl;
	}
    return 0;
}
//不AC洛谷炸
2021/3/12 19:42
加载中...