寻找金蝉素数

提交数: 94, 通过率: 42.55%, 平均分: 42.55

题目描述:

素数是指大于 1 的自然数中,除了 1 和它本身以外不再有其他因数的自然数。

金蝉素数是指由 1、 3、 5、 7、 9 这 5 个奇数排列组成不重复的五位素数,它的中间三位数和最中间的一位数也
都是素数的自然数,如“13597”是素数,“359”和“5”也是素数,则“13597”是金蝉素数。

输入格式:

输出格式:

一行内从小到大输出所有的金蝉素数,用空格隔开。

第二行输出总个数。

样例输入:

样例输出:

提示:

请完善程序:

#include<bits/stdc++.h>
using namespace std;

bool isPrime( int n ) {
	if ( n<2) return 0;
	for ( int i=2; i<= sqrt( n) ; i++)
		if ( n % i == 0) return 0;
	return 1;
}

int a[10], b[10001];
int main() {
	int tot = 0;
	for ( int i = 13579; i<=97531 ; i+=2 ) {
		memset( a, 0, sizeof a );
		int temp = i;
		while ( temp ) {
			____________________
			temp /= 10;
		}
		if ( a[1] + a[3] + a[5] + a[7] + a[9] == 5 ) {
			int x = _____________________
			int y = _____________________
			if ( ______________________________________ ) {
				____________________
				b[ tot ] = i;
			}
		}
	}
	cout << "Golden Cicada Prime: ";
	for ( int i=1; i<=tot; i++) cout << b[i]<<" ";
	cout << endl;	
	cout << "The sum is: "<< tot << endl;
	return 0;
}
时间限制: 1000ms
空间限制: 256MB

来源: 原创