2 条题解

  • 0
    @ 2025-9-6 17:33:58
    #include<bits/stdc++.h>
    using namespace std;
    bool zhishu(int n) 
    {
    	if (n<=1) 
    		return false;
    	for (int i=2;i<n;i++) 
    	{
    		if (n% i==0) 
    			return false;
    	}
    	return true;
    }//质数检测
    bool huiwen(int n)
    {
    	int a,b;
    	a=0;
    	b=n;
    	while(b>0)
    	{
    		a=a*10+b%10;
    		b=b/10;
    	}
    	if(a==n)
    		return true;
    	else
    		return false;
    }//回文数检测
    int main()
    {
    	int a,b,i,f,g,c;
    	cin>>a>>b;
    	for(i=a;i<=b;i++)
    	{
    		c=zhishu(i);
    		if(c==1)//true
    		{
    			c=huiwen(i);
    			if(c==1)
    				cout<<i<<endl;
    		}
    	} 
    	return 0;
    }
    

    信息

    ID
    187
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    递交数
    108
    已通过
    17
    上传者