66分,三个TLE
查看原帖
66分,三个TLE
1143775
__yiLIUyi__楼主2024/2/23 09:16

我的思路:先判断是不是回文,在判断是不是质数。

#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		int m=0;
		int n=i;
		while(n>0){
			m=n%10+m*10;
			n=n/10;
		}
		if(m==i){
			for(int u=2;u<i;u++){
				if(i%u==0)break;
				if(i%u!=0&&i-u==1)cout<<i<<" "<<endl;
			}
		}
	}
	return 0;
}
2024/2/23 09:16
加载中...