[kuangbin带你飞]专题一 简单搜索 - M - 非常可乐
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
bool cup[][][];
struct dot
{
int a;
int b;
int c;
int s;
};
int x, y, z;
bool flag; int clam(int a, int b, int c)
{
int s;
switch(c)
{
case : s = x; break;
case : s = y; break;
case : s = z; break;
}
if( a+b < s) return a;
else return s-b;
} int main()
{
// freopen("in.in","r",stdin);
// freopen("out.txt","w",stdout);
while(scanf("%d%d%d",&x,&y,&z),x|y|z)
{
if( x& )
{
printf( "NO\n" );
continue;
}
memset(cup,false,sizeof(cup));
flag = false;
queue<dot>q;
dot s, t;
s.a = x;
s.b = ;
s.c = ;
s.s = ;
q.push(s);
while(q.size())
{
s = q.front();
q.pop();
cup[s.a][s.b][s.c] = true; if((s.a==x/ && s.b==x/) || (s.c==x/ && s.b==x/) || (s.c==x/ && s.a==x/) )
{
flag = true;
break;
}
t.s = s.s + ; t.a = s.a - clam(s.a,s.b,);
t.b = s.b + clam(s.a,s.b,);
t.c = s.c;
if(cup[t.a][t.b][t.c]==false) q.push(t);
t.a = s.a + clam(s.b,s.a,);
t.b = s.b - clam(s.b,s.a,);
t.c = s.c;
if(cup[t.a][t.b][t.c]==false) q.push(t);
t.a = s.a;
t.b = s.b + clam(s.c,s.b,);
t.c = s.c - clam(s.c,s.b,);
if(cup[t.a][t.b][t.c]==false) q.push(t);
t.a = s.a;
t.b = s.b - clam(s.b,s.c,);
t.c = s.c + clam(s.b,s.c,);
if(cup[t.a][t.b][t.c]==false) q.push(t);
t.a = s.a - clam(s.a,s.c,);
t.b = s.b;
t.c = s.c + clam(s.a,s.c,);
if(cup[t.a][t.b][t.c]==false) q.push(t);
t.a = s.a + clam(s.c,s.a,);
t.b = s.b;
t.c = s.c - clam(s.c,s.a,);
if(cup[t.a][t.b][t.c]==false) q.push(t);
}
if(flag)
{
while(q.size()) q.pop();
printf("%d\n",s.s);
}
else printf("NO\n"); }
return ;
}
[kuangbin带你飞]专题一 简单搜索 - M - 非常可乐的更多相关文章
- [kuangbin带你飞]专题一 简单搜索 题解报告
又重头开始刷kuangbin,有些题用了和以前不一样的思路解决.全部题解如下 点击每道题的标题即可跳转至VJ题目页面. A-棋盘问题 棋子不能摆在相同行和相同列,所以我们可以依此枚举每一行,然后标记每 ...
- [kuangbin带你飞]专题一 简单搜索(回顾)
A - 棋盘问题 POJ - 1321 注意条件:不能每放一个棋子,就标记一行和一列,我们直接枚举每一行就可以了. AC代码: #include<iostream> #include< ...
- [kuangbin带你飞]专题一 简单搜索 - E - Find The Multiple
//Memory Time //2236K 32MS #include<iostream> using namespace std; ]; //保存每次mod n的余数 //由于198的余 ...
- [kuangbin带你飞]专题一 简单搜索 棋盘问题
题来:链接https://vjudge.net/problem/OpenJ_Bailian-132 J - 棋盘问题 1.题目: 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别. ...
- [kuangbin带你飞]专题一 简单搜索
ID Origin Title 454 / 1008 Problem A POJ 1321 棋盘问题 328 / 854 Problem B POJ 2251 Dungeon Ma ...
- [kuangbin带你飞]专题一 简单搜索 回顾总结
第二题:bfs,忘了将queue清空. 第三题:bfs,记得使用vis数组,防止重复入队
- 迷宫问题 POJ - 3984 [kuangbin带你飞]专题一 简单搜索
定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, ...
- [kuangbin带你飞]专题一 简单搜索 Find a way HDU - 2612
Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year ...
- Catch That Cow POJ - 3278 [kuangbin带你飞]专题一 简单搜索
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. ...
随机推荐
- NX二次开发-基于MFC界面的NX对Excel读写操作(OLE方式(COM组件))
NX二次开发API里没有对EXCAL读写操作的相关函数,市面上有很多种方法去实现,比如UFUN调KF,ODBC,OLE(COM组件)等等.这里我是用的OLE(COM组件)方式去做的,这种在VC上创建的 ...
- cgroup & oom-killer 简介
cgroup内存限制 memory.failcnt memory.limit_in_bytes memory.usage_in_bytes memory.max_usage_in_bytes memo ...
- 微软引入了两种新的网络过滤系统,WFP和NDISfilter
Windows 8是微软公司推出的最新的客户端OS,内部名称Windows NT 80.相对于Windows NT 5.x,其网络结构变化非常大,原有的TDI,NDIS系统挂接方法不再适用.在Wind ...
- 用java进行测试php写的接口
<?php /* * @Author: anchen * @Date: 2018-07-06 13:53:19 * @Last Modified by: anchen * @Last Modif ...
- Android逆向之smali语法宝典
0x01.前言 Android采用的是java语言进行开发,但是Android系统有自己的虚拟机Dalvik,代码编译最终不是采用的java的class,而是使用的smali.我们反编译得到的代码,j ...
- cmd 修改当前路径
cd 命令需要加/d,如:
- CodeForces-1249C2-Good Numbers (hard version) -巧妙进制/暴力
The only difference between easy and hard versions is the maximum value of n. You are given a positi ...
- 专题:『systemd』
[COMMAND] Systemd Daemons: systemd networkd journald logind "user session" Systemd units: ...
- 中山大学深圳研究院“智能金融和区块链技术”论坛(理论+实战PPT)
中山大学深圳研究院在昨天11月15号在深圳南山区虚拟大学园举办了"智能金融和区块链技术"论坛. 本次论坛邀请了中山大学移动互联网与金融大数据实验室郑子彬教授团队系统地介绍智能金融及 ...
- USACO 2001 OPEN earthquake /// 最优比例生成树
题目大意: https://www.cnblogs.com/forever97/p/3603572.html 讲解:https://www.jianshu.com/p/d40a740a527e 题解: ...