1 条题解

  • 0
    @ 2023-6-11 12:15:50

    C :

    #include<stdio.h>
    int ishw(int n){
    	int m=0,t,k=n;
    	while(k!=0){
    		t=k%10;
    		m=m*10+t;
    		k=k/10;
    	}
    	if(m==n){
    		return 1;
    	
    	}else{
    		return 0;
    	}
    }
    int iszs(int n){
    	int i;
    	if(n<2){
    		return 0;
    	} 
    	for(i=2;i<=n-1;i++){
    		if(n%i==0){
    			return 0;
    		}
    	}
    	return 1;
    }
    int main()
    {
    	int i;
    	for(i=10;i<=1000;i++){
    		if(ishw(i)==1&&iszs(i)==1){
    			printf("%d\n",i);
    		}
    	}
    
    
    
    
    return 0;
    }
    
    

    Python :

    import math
    def suShu(n):
            f = True
            for i in range (2 , int(math.sqrt(n))+1):
                    if n % i == 0:
                            f = False
                            break;
            return f and n != 1
    def hwsuShu(n):
            a = n // 100 % 10
            b = n // 10 % 10
            c = n % 10
            if n < 100:
                 return  b == c and  suShu(n);
            elif n > 100:
                 return  a == c and  suShu(n);
            else:
                 return False
    for i in range (10, 1000):
            if hwsuShu(i):
                    print(i)
    
    
    • 1

    信息

    ID
    2065
    时间
    1000ms
    内存
    16MiB
    难度
    3
    标签
    递交数
    83
    已通过
    43
    上传者