Section 1.4 Mother's Milk
来源:互联网 发布:外国人 汉字 知乎 编辑:程序博客网 时间:2024/05/22 21:09
由于数据过小, 采取枚举所以的方案
我采用的是递归 用vip(x, y, z) 表示 a, b, c杯中水的情况
另外采用Orz 过程模拟倒水情况 只要想清楚了 我是1次AC的
{
ID: yaoyaun4
PROG: milk3
LANG: PASCAL
}
Program milk3;
const inf = 'milk3.in'; outf = 'milk3.out';
var
a, b, c : longint;
f : array[0..20, 0..20] of longint;
ans : string;
Procedure init;
begin
assign(input, inf); reset(input);
readln(a, b, c);
close(input);
fillchar(f, sizeof(f), 255);
end;
Procedure orz(var i, j : longint; aj : Longint);
var
t : longint;
begin
t := aj - j;
if i > t then
begin
dec(i, t);
inc(j, t);
end
else
begin
inc(j, i);
i := 0;
end;
end;
Procedure vip(x, y, z : longint);
var
i, j : longint;
begin
if f[x, y] >= 0 then exit;
f[x, y] := z;
i := x; j := y; orz(i, j, b); vip(i, j, z);
i := x; j := z; orz(i, j, c); vip(i, y, j);
i := y; j := x; orz(i, j, a); vip(j, i, z);
i := y; j := z; orz(i, j, c); vip(x, i, j);
i := z; j := x; orz(i, j, a); vip(j, y, i);
i := z; j := y; orz(i, j, b); vip(x, j, i);
end;
Procedure work;
var
i : longint;
ch : string;
begin
vip(0, 0, c);
for i := 20 downto 0 do
if f[0, i] >= 0 then
begin
str(f[0, i], ch);
ans := ans + ch + ' ';
end;
delete(ans, length(ans), 1);
end;
Procedure print;
begin
assign(output, outf); rewrite(output);
writeln(ans);
close(output);
end;
begin
init;
work;
print;
end.
- Section 1.4 Mother's Milk
- USACO Section 1.4 Mother's Milk 搜索
- USACO section 1.4.4 Mother's Milk
- USACO Section 1.4 Mother's Milk
- USACO Section 1.4 Mother's Milk
- USCAO-Section 1.4 Mother's Milk
- USACO Section 1.4 Mother's Milk
- USACO Section 1.4 Mother's Milk - 输出错了好几次..
- USACO Section 1.4 - Mother's Milk(DFS + 记忆化)
- USACO-Section 1.4 Mother's Milk(BFS)
- 1.4Mother's Milk
- USCAO section Mother's Milk(搜索)
- 1.4.4 Mother's Milk
- [usaco]1.4 Mother’s Milk
- 1.4.4---Mother's Milk
- USACO 1.4 Mother's Milk
- USACO 1.4 Mother's Milk
- USACO 1.4-Mother's Milk
- EasyMock与Junit的集成测试
- 多线程:Thread类的Join()方法
- 在keil中编译ucos时要注意的问题
- Managed Code and Native Code
- POJ3260The Fewest Coins题解动态规划DP
- Section 1.4 Mother's Milk
- c++对象模型 内存布局
- C语言可变参数
- 位运算之美——用+,-和位运算实现正整数除法和取模(一)
- c++指针的使用总结——开始菜鸟之路!
- 摄像头接线 SM9C120A 1605
- winio 模拟按键(无PS2键盘,未测试)
- C++中 Static作用和使用方法(改正)
- XNA学习笔记——Tile Map的碰撞检测