1. Solve this cryptic equation， realizing of course that values for M and E
could be interchanged. No leading zeros are allowed.

//

bool IsCorrent( int dest)
… {

int wwwdot = dest[ 0 ]
( 100000 + 10000 + 1000 ) + dest[
1 ] 100 + dest[ 2 ] 10 + dest[ 3 ];

int google = dest[ 4 ] ( 100000 + 100 ) + dest[ 2 ] (
10000 + 1000 ) + dest[ 5 ] 10 + dest[ 6 ];

int dotcom = dest[ 1 ]
100000 + dest[ 2 ] ( 10000 + 10
) + dest[ 3 ]
1000 + dest[ 7 ] 100 + dest[ 8 ];

if (wwwdot - google == dotcom)
… {

return true ;
}

else
… {

return false ;
}
}

//

void All( int
src, int currentIndex, int len, int dest, int
num)
… {

if (currentIndex == len)

return ;

dest[num ++ ] = src[currentIndex ++ ];

if (num == 9 )
… {

Perm(dest, 0 , 8 , 9 );
}

All(src,currentIndex,len,dest,num);

All(src,currentIndex,len,dest,num - 1 );
}

//

void Perm( int
src, int current, int lesslen, int len)
… {

if (current == lesslen)
… {

if (IsCorrent(src))
… {

for ( int i = 0 ; i < len; i ++ )
… {

cout << src[i] << “ “ ;
}

cout << endl;
}
}

for ( int i = current; i < len; i ++ )
… {

swap(src[i],src[current]);

Perm(src,current + 1 ,lesslen,len);

swap(src[i],src[current]);
}

}

WDOTGLECM分别为7 5 8 9 1 0 6 4 3或7 5 8 9 1 0 3 4 6因为E和M可以互换，所以正解…..

• 本文作者： 帐前卒
• 本文链接： http://chillyc.info/2008/2011169/
• 版权声明： 本博客所有文章除特别声明外，只能复制超链接地址，且必须注明出处！