| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Announcement | Current Contest Past Contests Scheduled Contests Award Contest |
Roll Box II
Description Have
you solved the previous problem yet, my friend? As a kid, little Tom
has no much patience at all. He turns to play something which is more
interesting. Actually he is inventing his own 'Roll Box' game. Without
such many rules and constraints, the new 'Roll Box' game, which is
invented by little Tom, has an infinite plane with all of its cells
being rigid cells. (What? Don't know rigid cells? Go to 'Roll Box 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 for the box from the given initial cell to the target cell in
this infinite plane. Input Input
contains multiple test cases. Each test case contains one letter and
two integers on a single line which describes the initial cell and
state of the box. The letter will be either 'U' for stands Up, 'H' for
lies down towards increasing y axis or 'V' for lies down towards
incresing x axis. The two integers x, y (0 ¡Ü x, y ¡Ü 1000000000) is the only one cell that box stands on or the one closer to the origin from the two cells that box lies on. Output For each test cases output one line with the minimum number of moves, which the box could right stand on the origion cell (0,0). Sample Input Sample Output Hint The plane is infinite, so you may pass through some cell with negative coodinates if you want to. Source |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2007 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator