游戏是用网页做的,大家就把下面这个存成.htm文件再打开就是了:
<html><head><title>智力游戏(把所有按钮变成蓝色的)</title>
<style>
body{
  text-align:center;
background-color:#EAF5FF;
margin:0px;
font-size:12px;
font-family:"宋体";
}
table{
  table-layout: fixed;
border-collapse: collapse;
}
td{
  cursor:hand;
  overflow:hidden;
text-overflow:ellipsis;
  width:100px;
  height:100px;
  border:1px solid yellow;
}
td.x{
  background-color:red;
}
td.o{
  background-color:blue;
}
</style>
<script language="javascript">
var clk=0;
function init(){
  var gameborder=document.all.gameborder;
  for(var i=0;i<5;i++){
    var newRow=gameborder.insertRow();
    for(var j=0;j<5;j++){
      var newCell=newRow.insertCell();
      newCell.className="x";
      newCell.onclick=press;
    }
  }
}
function press(){
  clk++;
  this.className=this.className=="x"?"o":"x";
  if(this.cellIndex>0){
    var obj=this.parentElement.cells[this.cellIndex-1];
    obj.className=obj.className=="x"?"o":"x";
  }
  if(this.cellIndex<4){
    var obj=this.parentElement.cells[this.cellIndex+1];
    obj.className=obj.className=="x"?"o":"x";
  }
  var par=this.parentElement;
  if(par.rowIndex>0){
    var obj=par.parentElement.rows[par.rowIndex-1].cells[this.cellIndex];
    obj.className=obj.className=="x"?"o":"x";
  }
  if(par.rowIndex<4){
    var obj=par.parentElement.rows[par.rowIndex+1].cells[this.cellIndex];
    obj.className=obj.className=="x"?"o":"x";
  }
  testWin();
}
function testWin(){
  var gameborder=document.all.gameborder;
  for(var i=0;i<5;i++)
    for(var j=0;j<5;j++)
      if(gameborder.rows[i].cells[j].className=="x")return;
  alert("You win at take "+clk+" click");
}
</script></head><body onload="init();"><table id="gameborder"></table></body></html>

解决方案 »

  1.   

    以下为该游戏求解的程序:
    for(int i=0;i<0x1FFFFFF;i++){
          int above=i<<5;
          int underside=i>>5;
          int left=i<<1&0x1EF7BDE;
          int right=i>>1&0xF7BDEF;
          int result=i^above^underside^left^right;
          if((result&0x1FFFFFF)==0x1FFFFFF){
            String s="";
            for(int j=0;j<25;j++){
              s+=(i>>j&1)==1?" ●":" ○";
              if(j%5==4) s+="\r\n";
            }
            System.out.println(s);
          }
        }
      

  2.   

    首先,每个格子点偶数次,相当于没点,点奇数次则相当于点1次
    其次,成功的解法中,每个格子自己、上、下、左、右等5个位置中,必须有奇数个被点击
    由此2条规则可得:游戏的解一共是2的25次方个;每个解的结果中每个格子与上述5个位置的点击总数相关解题思路:
    1、循环2的25次方次,即0x1FFFFFF次(其实首尾的很多都是肉眼可排除的,不过不影响大局)
    2、每次循环得到一个整数,用这个整数的每一个二进制位对应这25个格子,位上为1表示该格子需要按下
    3、计算上、下、左、右四个方位,使其与中心位置对应(注意由于左右两边的边界问题,需要两个数相与,而上下由于位移时全为0不影响,所以不需要额外处理)
    4、计算该中心位置的最终结果,计算方式为统计上述5个位置的点击总数,若为奇数则成功,否则失败(最好的计算方式:异或,具体自行理解)
    5、判断每个格是否都成功,若全成功,则打印出当前解
      

  3.   

    windows xp 的exproler是不是打不开?
      

  4.   

    主要的解法,总共不到10行的java代码,300ms内计算完成。牛人!牛XX!