Peg Test - March 9
Question 6
Betty the cow loves eating candy canes. Unfortunately, she dropped her candy cane on a 10 × 10 grid. In her confusion, she wandered around and ended up at the lower left hand corner of the grid (1, 1). She also saw that there were some bombs placed on the grid (see diagram below), that she must avoid. Each step she takes now will make her sweat 1 mL, and her steps will always take her to an adjacent square on the grid. Given (x, y) (1 ≤ x,y ≤ 10), the coordinates of her candy cane, calculate the least amount of sweat that Betty sweats to reach her candy cane.
X | |||||||||
X | X | ||||||||
X | |||||||||
X | |||||||||
X | X | X | X | X | X | X | |||
X | |||||||||
X | X | ||||||||
X | |||||||||
B | X |
Input
Input contains two integers on a line separated by a space: x and y.
Output
The sentenceBetty will sweat XmL to get to her candy cane
where
X
is the minimum number of mL of
sweat that Betty must sweat to reach her candy cane.
Sample Input 1
4 3
Sample Output 1
Betty will sweat 5mL to get to her candy cane
Sample Input 2
4 7
Sample Output 2
Betty will sweat 21mL to get to her candy cane
All Submissions
Best Solutions
Point Value: 10 (partial)
Time Limit: 2.00s
Memory Limit: 16M
Added: Mar 10, 2011
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
It's quiet in here...