poj1753 flip game题解
来源:互联网 发布:生化危机4 知乎 编辑:程序博客网 时间:2024/05/05 09:43
#include<iostream>
using namespace std;
#include<cmath>
#define MAX 65536
const int a[16]={
0xc800,0xe400,0x7200,0x3100,
0x8c80,0x4e40,0x2720,0x1310,
0x08c8,0x04e4,0x0272,0x0131,
0x008c,0x004e,0x0027,0x0013,};
int main()
{
int front=0,rear=0;
int levelend=0,levelcount=0;
int flip[MAX],b[MAX]={0};
int i,j,k=0,temp,ni=1;
bool flag=true;
char ch;
for(i=0;i<16;i++)
{
cin>>ch;
j=(ch=='b'?1:0);
k+=(int)j*pow((double)2,15-i);
}
rear=(rear+1)%MAX;
flip[rear]=k;
while(flag&&front<=levelend)
{
while(front<=levelend)
{
front=(front+1)%MAX;
if(flip[front]==0xffff||flip[front]==0x0000)
{
flag=false;
break;
}
for(i=0;i<16;i++)
{
temp=flip[front]^a[i];
if(b[temp]==0)
{
rear=(rear+1)%MAX;
flip[rear]=temp;
b[temp]=1;
}
}
}
levelend=rear;
levelcount++;
}
if(front>levelend)
{
cout<<"Impossible";
}
else
{
cout<<levelcount-1;
}
return 0;
}
- poj1753 flip game题解
- poj1753 Flip Game
- poj1753 Flip Game
- poj1753 Flip Game
- POJ1753 Flip Game
- POJ1753-Flip Game
- poj1753 - Flip Game
- POJ1753 Flip Game
- poj1753 Flip Game
- POJ1753 Flip Game
- poj1753:Flip Game
- POJ1753 Flip Game【DFS】
- poj1753-Flip Game
- poj1753 Flip Game 广搜哈希
- poj1753--Flip Game
- poj1753 Flip Game
- POJ1753:Flip Game
- POJ1753 Flip Game 枚舉
- 数据质量
- ArcSDE性能优化之Shrink空间索引
- 管道PipedInputStream/PipedOutputStream类
- 多维查询表达式MDX基础知识介绍
- php截取中英文混合字符串方法
- poj1753 flip game题解
- IP多播技术
- Work with dates and times(C和C++程序设计中使用日期和时间)
- C# .ToString() 格式化
- 关于JavaScript的Object和Function的两张图
- 第二部分 连接跟踪
- 一步步的教你安装UChome (UChome 安装教程)
- 多进程机制术语-Polling
- mybatis相关学习资料以及插件