TLE on last
查看原帖
TLE on last
813696
chenhongyicc楼主2023/1/16 09:28
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,j,t;
string s1,s2;
ll cnt = 0;
bool flag = true;
bool zhi(int x){ // 质数
//	if(s=="M")return 0;
//	if(s[s.length()-1]=='S')return -s.length();
//	return s.length();
	for(int i = 2 ;i<=sqrt(x); i++){
		if(x%i == 0) return false;
	}
	return true;
}
int hw(int x){ //回文
	int t = x, xx = 0;
	while(t){
		xx = xx * 10 + t % 10;
		t/=10;
	}
	return xx == x;
}
bool fulls(int x){ // ÍêÈ«Êý 
	int sum = 1;
	for(int i = 2;i<=sqrt(x);i++){
		if(x%i == 0) sum+=i+x/i;
	}
	if(x == sum) return true;
	
	else return false;
}
bool lastx(int x){
	if (x == 11) return true;
	int cnt = 0;
	while(x){
		x/=10;
		cnt++;
	}
	if(cnt%2==0) return false;
	else return true;
}
int main(){
	scanf("%d%d",&n,&t);
	for(int i = n ;i<=t;i++){
		if(hw(i) && zhi(i)) printf("%d\n",i);
	}
	

// tle on last 88 pts
	return 0;
}

最后一个点TLE,也想不到有啥可优化的了,求助。

2023/1/16 09:28
加载中...