最后一个点TLE QAQ
查看原帖
最后一个点TLE QAQ
192202
leisureliness楼主2020/8/23 11:21

介是我的代码

#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
bool pan(int j);
bool sh(int i);
int main()
{
	int a,b;
	cin>>a>>b;
	for (int i=a;i<=b;++i)
	{
		if (pan(i)==true)
			if (sh(i)==true)
			cout<<i<<endl;
	}
	return 0;
}
bool sh(int i)
{
	bool f=false;
	int x=2;
	while (x<=floor(sqrt(i))&&(i%x!=0))
	x++;
	if (x>floor(sqrt(i)))
		f=true;
	return f;
}	
bool pan(int j)
{
	int e[8]={};
	int k=0;
	while (j!=0)
	{
		k++;
		e[k]=j%10;
		j/=10;
	}
	int d=1;
	while ((d<k)&&(e[d]==e[k]))
	{
		k--;
		d++;
	}
	if (d>=k)
		return true;
	else 
		return false;
}
2020/8/23 11:21
加载中...