社区讨论

卫生么输出0??0_0?

B2136素数回文数的个数参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@m1633da0
此快照首次捕获于
2024/09/17 14:59
去年
此快照最后确认于
2024/09/17 15:01
去年
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;

bool susu(int h)//判断素数
{
	for(int i=1;i<=sqrt(h)/*从1——n判断*/;i++)
	{
		if(h<2)
		{
			return false;	
		}
		if(h%i==0)
		{
			return false;
		}
	}
	return true;
}

bool hehe(int h)//判断回文数
{
	int t=h,n=0;
	while(t)
	{
		n=n*10+t%10;
		t/=10;
	}
	if(n==h)
	{
		return true;
	}
}

int main()
{
	int h,m=0;
	cin>>h;
	for(int i=11;i<=h;i++)
	{
		if(susu(i)&&hehe(i))
		{
			m++;
		}
	}
	cout<<m<<'\n';
	return 0;
}

回复

0 条回复,欢迎继续交流。

正在加载回复...