davewang @ 2019-03-14 23:24:51
using namespace std;
bool e[ 20000 ];
int prime[ 5300 ],len = 0;
void find_prime(int n)
{
if( n <= 10 )
{
prime[ 0 ] = 2;
prime[ 1 ] = 3;
prime[ 2 ] = 5;
prime[ 3 ] = 7;
e[ 1 ] = e[ 4 ] = e[ 6 ] = e[ 8 ] = e[ 9 ] = e[ 10 ] = false;
len = 4;
return ;
}
else
{
int l = sqrt( n );
find_prime( l );
for( int i = 0; i < len; i++ )
{
int num = prime[ i ], m = n / prime[i];
for( int j = 2; j <= m; j++)
{
if( e[ j num ] == true )
e[ j num ] = false;
}
}
for( int i = l + 1; i <= n; i++ )
{
if( e[ i ] == true )
prime[ len ++ ] = i;
}
return ;
}
}
int main()
{
memset( e, true, sizeof(e) );
find_prime(20000);
int n;
//printf( "%d %d\n", e[ 3 ], e[ 2003 ]);
//bool bo = true;
scanf( "%d", &n );
for(int i = 0; i < len; i++ )
{
int a = prime[ i ];
for(int j = i; j < len; j++)
{
int b = prime[ j ];
int c = n - a - b;
//printf( "%d %d %d\n", a, b, c );
if( e[ c ] == true && c >= 2 )
{
printf( "%d %d %d\n", a, b, c );
return 0;
}
}
}
return 0;
}
告诉我输出了一个0,我明明从2开始遍历的
报错全是像这样:
column 1 read 0 expected 3
求助
by WKAHPM @ 2019-03-15 00:00:08
希望更丰富的展现?使用Markdown
by yyc001 @ 2019-03-15 07:53:19
希望更丰富的展现?使用Markdown