#1#7#9WA求助
查看原帖
#1#7#9WA求助
1050484
Netherite_Pickaxe楼主2024/3/24 15:21

大家能帮我看一看为什么这样

#include<bits/stdc++.h>
#define rep(i,m,n,f) for(int (i)=(m);(i)<=(n);(i)+=(f))
#define crep(i,m,n,f) for(int (i)=(m);(i)<=(n);(i)+=(f))
#define drep(i,m,n,f) for(int (i)=(m);(i)>=(n);(i)-=(f))
#define xrep(i,m,n,f) for(int (i)=(m-1);(i)<=(n-1);(i)+=(f))
#define zrep(i,m,n,f) for(int (i)=(m-1);(i)>=(n-1);(i)-=(f))
using namespace std;
bool ispr(int x)
{
	for(int i=2;i<=sqrt(x);i+=1)
	{
		if(x%i==0)
		return false;
	}
	return true;
}
inline void print(int c)
{
	printf("%d\n",c);
}
inline void setup()
{
	//SOURCE
	int a,b;
	cin>>a>>b;
	int ans;
	for(int d1=2;d1<=9;d1+=1)
	{
		ans=d1;
		if(ispr(ans)==true and ans>=a and ans<=b)
		print(ans);
	}
	for(int d1=1;d1<=9;d1+=2) 
	{
        for(int d2=0;d2<=9;d2+=1) 
		{
            ans=100*d1+10*d2+d1;
            if(ispr(ans)==true and ans>=a and ans<=b)
            print(ans);
        }
    }
	for(int d1=1;d1<=9;d1+=2) 
	{
        for(int d2=0;d2<=9;d2+=1) 
		{
            for(int d3=0;d3<=9;d3+=1) 
		    {
                ans=10000*d1+1000*d2+100*d3+10*d2+d1;
                if(ispr(ans)==true and ans>=a and ans<=b)
                print(ans);
            }
        }
    }
    for(int d1=1;d1<=9;d1+=2) 
	{
        for(int d2=0;d2<=9;d2+=1) 
		{
            for(int d3=0;d3<=9;d3+=1) 
		    {
		    	for(int d4=0;d4<=9;d4+=1)
		    	{
                	ans=1000000*d1+100000*d2+10000*d3+1000*d4+100*d3+10*d2+d1;
                	if(ispr(ans)==true and ans>=a and ans<=b)
                	print(ans);
                }
            }
        }
    }
}
signed main()
{
	setup();
	exit(EXIT_SUCCESS);
}

无语

2024/3/24 15:21
加载中...