9 条题解
-
0
#include<bits/stdc++.h> using namespace std; long long len=0,a[10000000]; bool p(int x) { if(x < 2) return false; for(int i = 2 ; i * i <= x ; i++) if(x % i == 0) return false; return true; } void h(int x,int n) { int b[100],t = 0; int y = x; while(y) { b[t++] = y%10; y /= 10; } if(t * 2 == n || t * 2 - 1 == n) { if(t * 2 == n) x = x * 10 + b[0]; for(int i = 1; i < t ; i++) x = x * 10 + b[i]; if(p(x)) a[len++] = x; } } int main() { int n; cin >> n; for (int i = 1 ; i <= 100000 ; i++ ) h(i,n); cout<< len << endl ; for(int i = 0; i < len ; i++) cout<< a[i] <<' '; return 0; }
信息
- ID
- 1001
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 457
- 已通过
- 111
- 上传者