1. 程式人生 > >爆搜爆搜

爆搜爆搜

程式碼:

#include "iostream"
#include "cstdlib"
#include "cstring"
using namespace std;
int map[6];
int Ans=0;
int list[15][6]= {{0,0,1,1,1,1},
    {0,1,0,1,1,1},
    {0,1,1,0,1,1},
    {0,1,1,1,0,1},
    {0,1,1,1,1,0},
    {1,0,0,1,1,1},
    {1,0,1,0,1,1},
    {1,0,1,1,0,1},
    {1,0,1,1,1,0},
    {1,1,0,0,1,1},
    {1,1,0,1,0,1},
    {1,1,0,1,1,0},
    {1,1,1,0,0,1},
    {1,1,1,0,1,0},
    {1,1,1,1,0,0}
};
void dfs( int layer )
{
    if(layer==-1)
    {
        for ( int i=0; i<=5; i++)
            if(list[map[0]][i]+list[map[1]][i]+list[map[2]][i]+list[map[3]][i]+list[map[4]][i]+list[map[5]][i]!=4) return ;
//        	 for ( int i=0;i<=5;i++)
//        	  {
//        	     for ( int j=0;j<=5;j++)
//        	        cout << list[map[i]][j];
//        	     cout << endl;
//        	  }
//        	  cout << endl;
        Ans++;
        return ;
    }
    for ( int i=0; i<15; i++)
    {
        map[layer]=i;
        dfs(layer-1);
    }
    return ;
}
int main()
{
    memset(map,0,sizeof(map));
    dfs(5);
    cout << Ans << endl;
    return 0;
}
多看看,多看看。