9 条题解

  • 1
    @ 2026-11-1 19:57:24
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+10;
    int len=0,a[110000];
    bool prime(int x){
    	if(x<2) return false;
    	for(int i=2;i*i<=x;i++){
    		if(x%i==0)
    			return false;
    	}
    	return true;
    }
    void huiwen(int x,int n){
    	int b[100],tot=0;
    	int y=x;
    	while(y){
    		b[tot++]=y%10;
    		y/=10;
    	}
    	if(tot*2==n||tot*2-1==n){
    		if(tot*2==n){
    			x=x*10+b[0];
    		}
    		for(int i=1;i<tot;i++)
    			x=x*10+b[i];
    		if(prime(x)){
    			a[len++]=x;
    		}
    	}
    }
    int main(){
    	int n;
    	cin>>n;
    	for(int i=1;i<=100000;i++){
    		huiwen(i,n);
    	}
    	cout<<len<<endl;
    	for(int i=0;i<len;i++)
    		cout<<a[i]<<" ";
    	return 0;
    }
    

    信息

    ID
    1001
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    递交数
    457
    已通过
    111
    上传者