测评结果前面都是AC,最后三个是TLE,求大佬帮助
  • 板块题目总版
  • 楼主Smoley
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/7/2 14:48
  • 上次更新2023/11/3 11:53:38
查看原帖
测评结果前面都是AC,最后三个是TLE,求大佬帮助
998768
Smoley楼主2023/7/2 14:48
#include<bits/stdc++.h>
using namespace std;
int zs(int x){
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0){
			return 0;
			break;
		}
	}
	return 1;
}
int check(int i){
    int y=0,m;
    m=i;
    if(i<10)
    	return 1;
    else{
    	while(i>0){
    		y=i%10+y*10;
    		i=i/10;
		}
	}
	if(y==m)
	    return 1;
	else
	    return 0;
}
int main(){
	int a,b;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(zs(i)){
			if(check(i))
			    cout<<i<<endl;
		}
	}
	return 0;
}
2023/7/2 14:48
加载中...