6 条题解

  • 1
    @ 2026-10-17 11:37:30

    #include<bits/stdc++.h> using namespace std; const int N=1e5; int len=0,a[N];

    bool prime(int x){ if(x<2) return false; for(int i=2;ii<=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(tot2n||tot*2-1n){ if(tot2==n){ x=x10+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
    标签
    递交数
    428
    已通过
    102
    上传者