我是很奇怪的造回文数然后很奇怪的错了,求大佬帮忙
查看原帖
我是很奇怪的造回文数然后很奇怪的错了,求大佬帮忙
26715
hhelp146楼主2020/7/30 15:13
#include<bits/stdc++.h>
using namespace std;
bool zs(int n)
{
	for(int i=2;i<=sqrt(n);i++)
	{
		if(n%i==0) return 0;
	}
	return 1;
}
int main()
{
	int a,b;cin>>a>>b;
	if (a<=5&&b>=5) cout<<5<<endl;
	if(a<=7&&b>=7) cout<<7<<endl;
	if(a<=11&&b>=11) cout<<11<<endl;
	for(int i=10;i<=99;i++)
	{
		int x=i,y=i/10;while(y>0){x=x*10+y%10;y/=10;}
		if(x>b) return 0;
		if (zs(x)) cout<<x<<endl;
	}
	for(int i=10;i<=99;i++)
	{
		int x=i,y=i;while(y>0){x=x*10+y%10;y/=10;}
		if(x>b) return 0;
		if (zs(x)) cout<<x<<endl;
	}
	for(int i=100;i<=999;i++)
	{
		int x=i,y=i/10;while(y>0){x=x*10+y%10;y/=10;}
		if(x>b) return 0;
		if (zs(x)) cout<<x<<endl;
	}
	for(int i=100;i<=999;i++)
	{
		int x=i,y=i;while(y>0){x=x*10+y%10;y/=10;}
		if(x>b) return 0;
		if (zs(x)) cout<<x<<endl;
	}
	for(int i=1000;i<=9999;i++)
	{
		int x=i,y=i/10;while(y>0){x=x*10+y%10;y/=10;}
		if(x>b) return 0;
		if (zs(x)) cout<<x<<endl;
	}
	for(int i=1000;i<=9999;i++)
	{
		int x=i,y=i;while(y>0){x=x*10+y%10;y/=10;}
		if(x>b) return 0;
		if (zs(x)) cout<<x<<endl;
	}
	for(int i=10000;i<=99999;i++)
	{
		int x=i,y=i/10;while(y>0){x=x*10+y%10;y/=10;}
		if(x>b) return 0;
		if (zs(x)) cout<<x<<endl;
	}
	for(int i=10000;i<=99999;i++)
	{
		int x=i,y=i;while(y>0){x=x*10+y%10;y/=10;}
		if(x>b) return 0;
		if (zs(x)) cout<<x<<endl;
	}
	return 0;
}
2020/7/30 15:13
加载中...