超级难====>面试试题?!谁来解决

oicqkill 2005-09-16 05:08:34
问题:
现在有一个2维网格6 * 7,不知道哪些格中有黑点,
只知道竖向统计黑点数目是[左到右]:
2, 0, 4, 3, 4, 0
横向[上到下]:
4, 1, 2, 2, 1, 1

要求写出代码求那些网格中有黑点?并输出网格。
格式为:

0, 0, 1, 0, 1, 1
0, 1, 0, 1, 1, 0
.....


...全文
782 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
Benjamin_JI 2005-09-20
  • 打赏
  • 举报
回复
void print(int *p[7][6]);
int getsum(int *p[7][6],int row);
void setCol4(int *p[7][6]);
void setCol3(int *p[7][6]);
void setCol2(int *p[7][6]);
void setCol0(int *p[7][6]);

void print(int *p[7][6])
{ int i1,i2;
printf("\n----===========---------\n");
for(i1=0;i1<7;i1++)
{
for(i2=0;i2<6;i2++)
printf("%d",p[i1][i2]);
printf("\n");
}
}

int getsum(int *p[7][6],int row)
{
int i,j;
j=0;
for(i=0;i<6;i++) if(p[row][i]==1) j++;
return j;
}

void setCol4(int *p[7][6])
{ int i1,i2,i3,i4,i5,i;
for(i1=0;i1<4;i1++)
{
p[i1][4]=1;
for(i2=i1+1;i2<5;i2++)
{
p[i2][4]=1;
for(i3=i2+1;i3<6;i3++)
{
p[i3][4]=1;
for(i4=i3+1;i4<7;i4++)
{
p[i4][4]=1;
if(getsum(p,0)==4&&getsum(p,1)==1&&getsum(p,2)==2
&&getsum(p,3)==2&&getsum(p,4)==1&&getsum(p,5)==2
&&getsum(p,6)==1)
print(p);
p[i4][4]=0;
}
p[i3][4]=0;
}
p[i2][4]=0;
}
p[i1][4]=0;
}
}

void setCol3(int *p[7][6])
{ int i1,i2,i3,i4;
for(i1=0;i1<4;i1++)
{
p[i1][3]=1;
for(i2=i1+1;i2<5;i2++)
{
p[i2][3]=1;
for(i3=i2+1;i3<6;i3++)
{
p[i3][3]=1;
setCol4(p);
p[i3][3]=0;
}
p[i2][3]=0;
}
p[i1][3]=0;
}
}

void setCol2(int *p[7][6])
{ int i1,i2,i3,i4;
for(i1=0;i1<4;i1++)
{
p[i1][2]=1;
for(i2=i1+1;i2<5;i2++)
{
p[i2][2]=1;
for(i3=i2+1;i3<6;i3++)
{
p[i3][2]=1;
for(i4=i3+1;i4<7;i4++)
{
p[i4][2]=1;
setCol3(p);
p[i4][2]=0;
}
p[i3][2]=0;
}
p[i2][2]=0;
}
p[i1][2]=0;
}
}

void setCol0(int *p[7][6])
{ int i1,i2;
i1=1;
i2=0;
for(i1=0;i1<6;i1++)
{
p[i1][0]=1;
for(i2=i1+1;i2<7;i2++)
{
p[i2][0]=1;
setCol2(p);
p[i2][0]=0;
}
p[i1][0]=0;
}
}

main()
{
int a[7][6];
int i1,i2;
for(i1=0;i1<7;i1++)
for(i2=0;i2<6;i2++)
a[i1][i2]=0;
setCol0(&a);
/* print(&a); */
}
oicqkill 2005-09-19
  • 打赏
  • 举报
回复
C++:
C++
/*
问题:
现在有一个2维网格6 * 7,不知道哪些格中有黑点,
只知道竖向统计黑点数目是[左到右]:
2, 0, 4, 3, 4, 0
横向[上到下]:
4, 1, 2, 2, 1, 2, 1

要求写出代码求那些网格中有黑点?并输出网格。
格式为:

0, 0, 1, 0, 1, 1
0, 1, 0, 1, 1, 0
.....
*/

#include <stdlib.h>
#include "string.h"
#include "stdio.h"

int limit[2][10] = {
{ 6, 2, 0, 4, 3, 4, 0 },
{ 7, 4, 1, 2, 2, 1, 2, 1 }
};

int foo_test( int * limits[2], int m_depth, int n_depth, void (* process) ( int, const int *, int, int ) )
{
static int * flags = NULL, ** stat = NULL, start[2] = { 0 }, cnt = 0;
const int width = limits[0][0], height = limits[1][0];
int idx[2], count = cnt;

if( !flags ) {
start[0] = m_depth, start[1] = n_depth;
flags = (int *) malloc( width * height * sizeof( int ) );
memset( flags, 0, width * height * sizeof( int ) );
stat = (int **) malloc( 2 * sizeof( int * ) );
stat[0] = (int *) malloc( width * sizeof( int ) );
stat[1] = (int *) malloc( height * sizeof( int ) );
memset( stat[0], 0, width * sizeof( int ) );
memset( stat[1], 0, height * sizeof( int ) );
}
idx[0] = m_depth - start[0], idx[1] = n_depth - start[1];

if( idx[0] < width && idx[1] < height
&& stat[0][idx[0]] <= limits[0][idx[0] + 1]
&& stat[1][idx[1]] <= limits[1][idx[1] + 1] ) {
if( stat[0][idx[0]] < limits[0][idx[0] + 1]
&& stat[1][idx[1]] < limits[1][idx[1] + 1] ) {
/* is setable, set and test */
++stat[0][idx[0]], ++stat[1][idx[1]], flags[idx[1] * width + idx[0]] = 1;
if( limits[0][idx[0] + 1] - stat[0][idx[0]] <= height - ( idx[1] + 1 )
&& limits[1][idx[1] + 1] - stat[1][idx[1]] <= width - ( idx[0] + 1 ) ) {
/* test next */
if( idx[0] + 1 == width && stat[1][idx[1]] == limits[1][idx[1] + 1] ) {
foo_test( limits, start[0], n_depth + 1, process );
} else {
foo_test( limits, m_depth + 1, n_depth, process );
}
}
flags[idx[1] * width + idx[0]] = 0, --stat[0][idx[0]], --stat[1][idx[1]];
}
/* clear and test */
flags[idx[1] * width + idx[0]] = 0;
if( limits[0][idx[0] + 1] - stat[0][idx[0]] <= height - ( idx[1] + 1 )
&& limits[1][idx[1] + 1] - stat[1][idx[1]] <= width - ( idx[0] + 1 ) ) {
/* test next */
if( idx[0] + 1 == width && stat[1][idx[1]] == limits[1][idx[1] + 1] ) {
foo_test( limits, start[0], n_depth + 1, process );
} else {
foo_test( limits, m_depth + 1, n_depth, process );
}
}
} else if( idx[1] == height ) {
process( ++cnt, flags, width, height );
}

count = cnt - count;
if( m_depth == start[0] && n_depth == start[1] ) {
free(stat[1]);
free(stat[0]);
free(stat);
stat = NULL;
free(flags);
flags = NULL;
start[0] = start[1] = 0;
cnt = 0;
}

return count;
}

void output_result( int id, const int * arr, int m, int n )
{
int i, j, idx;
idx = 0;
printf( "> No %d :\n", id );
for( i = n; i--; ) {
for( j = m; j; ) {
printf( ( j-- < m ? ", %d" : " %d" ), arr[idx++] );
}
printf( "\n" );
}
}

void main()
{
int * limits[2];
limits[0] = limit[0], limits[1] = limit[1];

printf( "total %d plans\n", foo_test(limits, 0, 0, output_result ) );
}


/*
问题:
现在有一个2维网格6 * 7,不知道哪些格中有黑点,
只知道竖向统计黑点数目是[左到右]:
2, 0, 4, 3, 4, 0
横向[上到下]:
4, 1, 2, 2, 1, 2, 1

要求写出代码求那些网格中有黑点?并输出网格。
格式为:

0, 0, 1, 0, 1, 1
0, 1, 0, 1, 1, 0
.....
*/
#include <stdlib.h>
#include "string.h"
#include "stdio.h"


int limit[2][10] = {
{ 6, 2, 0, 4, 3, 4, 0 },
{ 7, 4, 1, 2, 2, 1, 2, 1 }
};

int foo_test( int * limits[2], int m_depth, int n_depth, void (* process) ( int, const int *, int, int ) )
{
static int * flags = NULL, ** stat = NULL, start[2] = { 0 }, cnt = 0;
const int width = limits[0][0], height = limits[1][0];
int idx[2], count = cnt;

if( !flags ) {
start[0] = m_depth, start[1] = n_depth;
flags = (int *) malloc( width * height * sizeof( int ) );
memset( flags, 0, width * height * sizeof( int ) );
stat = (int **) malloc( 2 * sizeof( int * ) );
stat[0] = (int *) malloc( width * sizeof( int ) );
stat[1] = (int *) malloc( height * sizeof( int ) );
memset( stat[0], 0, width * sizeof( int ) );
memset( stat[1], 0, height * sizeof( int ) );
}
idx[0] = m_depth - start[0], idx[1] = n_depth - start[1];

if( idx[0] < width && idx[1] < height
&& stat[0][idx[0]] <= limits[0][idx[0] + 1]
&& stat[1][idx[1]] <= limits[1][idx[1] + 1] ) {
if( stat[0][idx[0]] < limits[0][idx[0] + 1]
&& stat[1][idx[1]] < limits[1][idx[1] + 1] ) {
/* is setable, set and test */
++stat[0][idx[0]], ++stat[1][idx[1]], flags[idx[1] * width + idx[0]] = 1;
if( limits[0][idx[0] + 1] - stat[0][idx[0]] <= height - ( idx[1] + 1 )
&& limits[1][idx[1] + 1] - stat[1][idx[1]] <= width - ( idx[0] + 1 ) ) {
/* test next */
if( idx[0] + 1 == width && stat[1][idx[1]] == limits[1][idx[1] + 1] ) {
foo_test( limits, start[0], n_depth + 1, process );
} else {
foo_test( limits, m_depth + 1, n_depth, process );
}
}
flags[idx[1] * width + idx[0]] = 0, --stat[0][idx[0]], --stat[1][idx[1]];
}
/* clear and test */
flags[idx[1] * width + idx[0]] = 0;
if( limits[0][idx[0] + 1] - stat[0][idx[0]] <= height - ( idx[1] + 1 )
&& limits[1][idx[1] + 1] - stat[1][idx[1]] <= width - ( idx[0] + 1 ) ) {
/* test next */
if( idx[0] + 1 == width && stat[1][idx[1]] == limits[1][idx[1] + 1] ) {
foo_test( limits, start[0], n_depth + 1, process );
} else {
foo_test( limits, m_depth + 1, n_depth, process );
}
}
} else if( idx[1] == height ) {
process( ++cnt, flags, width, height );
}

count = cnt - count;
if( m_depth == start[0] && n_depth == start[1] ) {
free(stat[1]);
free(stat[0]);
free(stat);
stat = NULL;
free(flags);
flags = NULL;
start[0] = start[1] = 0;
cnt = 0;
}

return count;
}

void output_result( int id, const int * arr, int m, int n )
{
int i, j, idx;
idx = 0;
printf( "> No %d :\n", id );
for( i = n; i--; ) {
for( j = m; j; ) {
printf( ( j-- < m ? ", %d" : " %d" ), arr[idx++] );
}
printf( "\n" );
}
}

void main()
{
int * limits[2];
limits[0] = limit[0], limits[1] = limit[1];

printf( "total %d plans\n", foo_test( limits, 0, 0, output_result ) );
}
mengjj 2005-09-19
  • 打赏
  • 举报
回复
/*
问题:
现在有一个2维网格6 * 7,不知道哪些格中有黑点,
只知道竖向统计黑点数目是[左到右]:
2, 0, 4, 3, 4, 0
横向[上到下]:
4, 1, 2, 2, 1, 2, 1

要求写出代码求那些网格中有黑点?并输出网格。
格式为:

0, 0, 1, 0, 1, 1
0, 1, 0, 1, 1, 0
.....

*/


#include <iostream.h>

#define COL 6
#define ROW 7

const int c[COL]={2,0,4,3,4,0};
const int r[ROW]={4,1,2,2,1,2,1};

void CopyArray(bool source[][COL], bool dest[][COL])
{
for (int i=0; i<ROW; i++)
{
for (int j=0; j<COL; j++)
{
dest[i][j]=source[i][j];
}
}
}

void ListArray(bool source[][COL], int row, int col)
{
int i,j;
if (row>=ROW)
{
row=ROW-1;
for (i=0; i<COL; i++)
{
int temp=0;
for (j=0; j<ROW; j++)
{
if (source[j][i])
temp++;
}
if (temp!=c[i])
return;
}
for (i=0; i<ROW; i++)
{
for (int j=0; j<COL; j++)
{
if (source[i][j])
cout<<1<<" ";
else
cout<<0<<" ";
}
cout<<endl;
}
cout<<endl;
return;
}

int count=0;
for (i=0; i<col; i++)
{
if (source[row][i])
count++;
}
count=r[row]-count;

if (count<=0)
{
bool dest[ROW][COL];
CopyArray(source,dest);
ListArray(dest,row+1,0);
return;
}

for (i=col; i<=(COL-count); i++)
{
bool dest[ROW][COL];
CopyArray(source,dest);
dest[row][i]=true;
if (i==(COL-1))
{
ListArray(dest,row+1,i);
}
else
{
ListArray(dest,row,i+1);
}
}
}

void main()
{
bool a[ROW][COL];
for (int i=0; i<ROW; i++)
{
for (int j=0; j<COL; j++)
{
a[i][j]=false;
}
}
ListArray(a,0,0);
}
SammyLan 2005-09-17
  • 打赏
  • 举报
回复
MARK
xxandxx 2005-09-17
  • 打赏
  • 举报
回复
第一个g( a, newb, c )应该是g( a, newa, c )
我打错了
xxandxx 2005-09-17
  • 打赏
  • 举报
回复
函数f()功能:参数a,b是横行和竖行统计黑点数列,c,d是数列的大小,box是c*d的二维数组用来存放最终结果,并以初始化为所有元素全为0,函数完成后返回true;如果输入错误,返回false;
这个函数直接构造出一个满足条件的结果

bool f ( int *a, int *b, int *box, int c, int d )
{
int i, pone, ptwo, *newa, *newb;
bool flag;
pone = ptwo = 0;
for ( i = 0; i < c; ++i )
{
pone += a[i];
}
for ( i = 0; i < d; ++i )
{
ptwo += b[i];
}
if ( pone != ptwo ) return false;

pone = ptwo = 0;
newa = new int [c];
newb = new int [d];

g ( a, newb, c ); //函数g()把数组a的值按升序排入newa中,a数组元
g ( b, newb, d ); //素个数为c,代码大家都会,我就不写了

while ( newa[pone] && newa[ptwo] )
{
if ( newa[pone] == 0 ) ++pone;
if ( newb[ptwo] == 0 ) ++ptwo;
}

while ( pone != c && ptwo != d )
{
flag = newa[pone] > newb[ptwo];

if ( flag )
{
for ( i = 0; i < newb[ptwo]; ++i )
{
box [pone+i][ptwo] = 1;
--newa[pone+i];
}
++ptwo;
}
else
{
for ( i = 0; i < newa[pone]; ++i )
{
box [pone][ptwo+i] = 1;
--newb[pone+i];
}
++pone;
}
}

delete[] newa;
delete[] newb;
return true;
}
Leaveye 2005-09-17
  • 打赏
  • 举报
回复
/*
问题:
现在有一个2维网格6 * 7,不知道哪些格中有黑点,
只知道竖向统计黑点数目是[左到右]:
2, 0, 4, 3, 4, 0
横向[上到下]:
4, 1, 2, 2, 1, 2, 1

要求写出代码求那些网格中有黑点?并输出网格。
格式为:

0, 0, 1, 0, 1, 1
0, 1, 0, 1, 1, 0
.....
*/

#include <stdlib.h>

int limit[2][10] = {
{ 6, 2, 0, 4, 3, 4, 0 },
{ 7, 4, 1, 2, 2, 1, 2, 1 }
};

int foo_test( const int * limits[2], int m_depth, int n_depth, void (* process) ( int, const int *, int, int ) )
{
static int * flags = NULL, ** stat = NULL, start[2] = { 0 }, cnt = 0;
const int width = limits[0][0], height = limits[1][0];
int idx[2], count = cnt;

if( !flags ) {
start[0] = m_depth, start[1] = n_depth;
flags = (int *) malloc( width * height * sizeof( int ) );
memset( flags, 0, width * height * sizeof( int ) );
stat = (int **) malloc( 2 * sizeof( int * ) );
stat[0] = (int *) malloc( width * sizeof( int ) );
stat[1] = (int *) malloc( height * sizeof( int ) );
memset( stat[0], 0, width * sizeof( int ) );
memset( stat[1], 0, height * sizeof( int ) );
}
idx[0] = m_depth - start[0], idx[1] = n_depth - start[1];

if( idx[0] < width && idx[1] < height
&& stat[0][idx[0]] <= limits[0][idx[0] + 1]
&& stat[1][idx[1]] <= limits[1][idx[1] + 1] ) {
if( stat[0][idx[0]] < limits[0][idx[0] + 1]
&& stat[1][idx[1]] < limits[1][idx[1] + 1] ) {
/* is setable, set and test */
++stat[0][idx[0]], ++stat[1][idx[1]], flags[idx[1] * width + idx[0]] = 1;
if( limits[0][idx[0] + 1] - stat[0][idx[0]] <= height - ( idx[1] + 1 )
&& limits[1][idx[1] + 1] - stat[1][idx[1]] <= width - ( idx[0] + 1 ) ) {
/* test next */
if( idx[0] + 1 == width && stat[1][idx[1]] == limits[1][idx[1] + 1] ) {
foo_test( limits, start[0], n_depth + 1, process );
} else {
foo_test( limits, m_depth + 1, n_depth, process );
}
}
flags[idx[1] * width + idx[0]] = 0, --stat[0][idx[0]], --stat[1][idx[1]];
}
/* clear and test */
flags[idx[1] * width + idx[0]] = 0;
if( limits[0][idx[0] + 1] - stat[0][idx[0]] <= height - ( idx[1] + 1 )
&& limits[1][idx[1] + 1] - stat[1][idx[1]] <= width - ( idx[0] + 1 ) ) {
/* test next */
if( idx[0] + 1 == width && stat[1][idx[1]] == limits[1][idx[1] + 1] ) {
foo_test( limits, start[0], n_depth + 1, process );
} else {
foo_test( limits, m_depth + 1, n_depth, process );
}
}
} else if( idx[1] == height ) {
process( ++cnt, flags, width, height );
}

count = cnt - count;
if( m_depth == start[0] && n_depth == start[1] ) {
free(stat[1]);
free(stat[0]);
free(stat);
stat = NULL;
free(flags);
flags = NULL;
start[0] = start[1] = 0;
cnt = 0;
}

return count;
}

void output_result( int id, const int * arr, int m, int n )
{
int i, j, idx;
idx = 0;
printf( "> No %d :\n", id );
for( i = n; i--; ) {
for( j = m; j; ) {
printf( ( j-- < m ? ", %d" : " %d" ), arr[idx++] );
}
printf( "\n" );
}
}

void main()
{
int * limits[2];
limits[0] = limit[0], limits[1] = limit[1];

printf( "total %d plans\n", foo_test( limits, 0, 0, output_result ) );
}
Leaveye 2005-09-17
  • 打赏
  • 举报
回复
/*
问题:
现在有一个2维网格6 * 7,不知道哪些格中有黑点,
只知道竖向统计黑点数目是[左到右]:
2, 0, 4, 3, 4, 0
横向[上到下]:
4, 1, 2, 2, 1, 2, 1

要求写出代码求那些网格中有黑点?并输出网格。
格式为:

0, 0, 1, 0, 1, 1
0, 1, 0, 1, 1, 0
.....
*/

#include <stdlib.h>

int limit[2][10] = {
{ 6, 2, 0, 4, 3, 4, 0 },
{ 7, 4, 1, 2, 2, 1, 2, 1 }
};

int foo_test( const int * limits[2], int m_depth, int n_depth, void (* process) ( int, const int *, int, int ) )
{
static int * flags = NULL, ** stat = NULL, start[2] = { 0 }, cnt = 0;
const int width = limits[0][0], height = limits[1][0];
int idx[2], count = cnt;

if( !flags ) {
start[0] = m_depth, start[1] = n_depth;
flags = (int *) malloc( width * height * sizeof( int ) );
memset( flags, 0, width * height * sizeof( int ) );
stat = (int **) malloc( 2 * sizeof( int * ) );
stat[0] = (int *) malloc( width * sizeof( int ) );
stat[1] = (int *) malloc( height * sizeof( int ) );
memset( stat[0], 0, width * sizeof( int ) );
memset( stat[1], 0, height * sizeof( int ) );
}
idx[0] = m_depth - start[0], idx[1] = n_depth - start[1];

if( idx[0] < width && idx[1] < height
&& stat[0][idx[0]] <= limits[0][idx[0] + 1]
&& stat[1][idx[1]] <= limits[1][idx[1] + 1] ) {
if( stat[0][idx[0]] < limits[0][idx[0] + 1]
&& stat[1][idx[1]] < limits[1][idx[1] + 1] ) {
/* is setable, set and test */
++stat[0][idx[0]], ++stat[1][idx[1]], flags[idx[1] * width + idx[0]] = 1;
if( limits[0][idx[0] + 1] - stat[0][idx[0]] <= height - ( idx[1] + 1 )
&& limits[1][idx[1] + 1] - stat[1][idx[1]] <= width - ( idx[0] + 1 ) ) {
/* test next */
if( idx[0] + 1 == width && stat[1][idx[1]] == limits[1][idx[1] + 1] ) {
foo_test( limits, start[0], n_depth + 1, process );
} else {
foo_test( limits, m_depth + 1, n_depth, process );
}
}
flags[idx[1] * width + idx[0]] = 0, --stat[0][idx[0]], --stat[1][idx[1]];
}
/* clear and test */
flags[idx[1] * width + idx[0]] = 0;
if( limits[0][idx[0] + 1] - stat[0][idx[0]] <= height - ( idx[1] + 1 )
&& limits[1][idx[1] + 1] - stat[1][idx[1]] <= width - ( idx[0] + 1 ) ) {
/* test next */
if( idx[0] + 1 == width && stat[1][idx[1]] == limits[1][idx[1] + 1] ) {
foo_test( limits, start[0], n_depth + 1, process );
} else {
foo_test( limits, m_depth + 1, n_depth, process );
}
}
} else if( idx[1] == height ) {
process( ++cnt, flags, width, height );
}

count = cnt - count;
if( m_depth == start[0] && n_depth == start[1] ) {
free(stat[1]);
free(stat[0]);
free(stat);
stat = NULL;
free(flags);
flags = NULL;
start[0] = start[1] = 0;
cnt = 0;
}

return count;
}

void output_result( int id, const int * arr, int m, int n )
{
int i, j, idx;
idx = 0;
printf( "> No %d :\n", id );
for( i = n; i--; ) {
for( j = m; j; ) {
printf( ( j-- < m ? ", %d" : " %d" ), arr[idx++] );
}
printf( "\n" );
}
}

void main()
{
int * limits[2];
limits[0] = limit[0], limits[1] = limit[1];

printf( "total %d plans\n", foo_test( limits, 0, 0, output_result ) );
}
Leaveye 2005-09-16
  • 打赏
  • 举报
回复
回溯即可
xxandxx 2005-09-16
  • 打赏
  • 举报
回复
解不是唯一的
* 0 * * * 0
0 0 0 0 * 0
0 0 * * 0 0
0 0 * * 0 0
0 0 0 0 * 0
* 0 * 0 0 0
0 0 0 0 * 0
xxandxx 2005-09-16
  • 打赏
  • 举报
回复
1 0 1 1 1 0
0 0 0 0 1 0
1 0 1 0 0 0
0 0 1 1 0 0
0 0 0 0 1 0
0 0 1 1 0 0
0 0 0 0 1 0
tjz2008 2005-09-16
  • 打赏
  • 举报
回复
int a[6][7]={.......} //全由0,1组成;
int i,j;
for{i=0;i<6;i++}
{
a[i][0]=2;
a[i][1]=0;
a[i][2]=4;
a[i][3]=3;
a[i][4]=4;
a[i][5]=0;
}
for{j=0;j<7;j++}
{
a[0][j]=4;
a[1][j]=1;
a[2][j]=2;
a[3][j]=2;
a[4][j]=1;
a[5][j]=2;
a[6][j]=1;
}
可以用这样表示吧?偶是菜鸟
请高手完善之
xiaocai0001 2005-09-16
  • 打赏
  • 举报
回复
是啊
相当于一个(0-1)线性方程组的求解问题.
6*7个变量
13个方程.
应该有一个基础解系,答案不唯一
jixingzhong 2005-09-16
  • 打赏
  • 举报
回复
一个线形方程组 ......
oicqkill 2005-09-16
  • 打赏
  • 举报
回复
Rodge(三年了,还在摸索中) 的回答很不错 的,谁能给代码呢 ?光理论不切实际的
Rodge 2005-09-16
  • 打赏
  • 举报
回复
是4×6
Rodge 2005-09-16
  • 打赏
  • 举报
回复
根据题目的特殊性可以横向穷举。
6×7的矩阵可以退化为3×6。
因为第一行和第二列,第五列的黑点分部是确定的。
Rodge 2005-09-16
  • 打赏
  • 举报
回复
竖向穷举,

第一列只有2个点,第三列4个点,第4列3个点,第五列4个点。
然后判断是否符合横向的要求。

总共大概C7\2 * C7\4 * C7\3 * C7\4次。

C7\n表示数学里的组合数。
oicqkill 2005-09-16
  • 打赏
  • 举报
回复
sorry,写掉了
横向[上到下]:
4, 1, 2, 2, 1, 2, 1
yan_hai_bin 2005-09-16
  • 打赏
  • 举报
回复
是不是打错了,怎么横向纵向的统计都是六个数据
加载更多回复(2)

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧