poj3323翻译


Poj3323:Bloxorz2


Description


Have you solved the previous problem yet,my friend? As a kid, little Tom has no much patience at all. He turns to playsomething which is more interesting. Actually he is inventing his own 'Bloxorz'game. Without such many rules and constraints, the new 'Bloxorz' game, which isinvented by little Tom, has an infinite plane with all of its cells being rigidcells. (What? Don't know rigid cells? Go to 'Bloxorz I' for more information.)


With the target cell stably located cell(0,0), your task is to tell little Tom what is the minimum number of moves forthe box from the given initial cell to the target cell in this infinite plane.


Input


Input contains multiple test cases. Eachtest case contains one letter and two integers on a single line which describesthe initial cell and state of the box. The letter will be either 'U' for standsUp, 'H' for lies down towards increasing y axis or 'V' for lies down towardsincresing x axis. The two integers xy (0 ≤ xy ≤1000000000) is the only one cell that box stands on or the one closer to theorigin from the two cells that box lies on.


Output


For each test cases output one line withthe minimum number of moves, which the box could right stand on the origioncell (0,0).


Sample Input


U 0 0


H 0 0


V 1 0


Sample Output


0


4


1


Hint


The plane is infinite, so you may passthrough some cell with negative coodinates if you want to.



picture of the coordinate


 


Source


POJMonthly--2007.08.05, Rainer


 


 


 


 


 


 


 


 


 


 


翻译:


Poj3323


题目描述:


我的朋友,你有没有解决上一期问题呢?作为一个孩子,小汤姆没有多大耐性。他又开始玩了一些更加有趣的东西。实际上他是在研发一款新的,他自己的’Bloxorz’游戏。没有那么多的规矩和约束,这个由小汤姆发明的新的’Bloxorz’游戏,有一个无限的平面,所有的都是坚固的格子(神马玩意?不知道什么是坚固的格子?请看’BloxorzI’来获得更多信息。)。


目的地格子(坐标(0,0))。你的任务是告诉小汤姆在这个无限的平面中从箱子的位置到达目的地的最小距离。


输入格式:


输入包含多组测试数据。每一组测试(一行)数据包括一个字母和两个int类型整数,分别描述的最开始箱子所在位置和状态。’U’表示站着,’H’表示平行于x轴躺着,’V’表示平行于y轴躺着。两个整数xy(0 ≤ x, y ≤ 1000000000)是箱子站立的一个的格子,或者是箱子躺着的格子中的一个(另一个是相邻的)。


输出格式:


对于每一组测试数据输出移动最小步数,令箱子站在(0,0)上。


输入示例:


U 0 0


H 0 0


V 1 0


输出示例:


0


4


1


注意事项:


由于平面是无限的,所以你可以穿越一些负坐标点如果需要的话。



坐标图如上。


 


备注:


每月POJ2007.08.05Rainer原创


翻译:ysmor


 




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值