文理学院程序设计在线练习


ACM-Orz

Time Limit: 1 Second(s)    Memory Limit: 32 MB

Total Submission(s): 0   Accepted Submission(s): 0
Problem Description

ACM-Orz is an exciting game. The target of this game is to roll a box onto a specified position of a plane. The box is a cuboid with size 1*1*h ,and the plane is a rectangle with size n*m. We call the status of the box covering only a unit of area “Standing Up”.And the other status “Laying down”. 
Each step it’s allowed to move the box in four directions. The movement is defined as picking one of the the four edges of the box on the ground and rotate the box 90 degrees around that edge. 
Take h=2,n=5,m=4 for example, the box is now “Standing Up” on position (2,3), as the following picture shows.


If you going down in one move , the box is now “Laying down” with the top-left unit touching (3,3). Of course this box can never go out of the plane. So it’s impossible to go right or up in the previous status.


Now given n,m,h, and the box is initially “Standing Up” on position (1,1),your task is to find the minimum steps needed to make the box “Standing Up” on position (n,m), or to determine it’s impossible.

Input

There are multiple test cases. Given n,m,h(0<n,m <10,000,000,0<h<10) as described before in one line. Process to end of file.

Output

Print the minimum steps needed to make the box “Standing Up” on position (n,m) in one line, or print -1 if it’s impossible.

Sample Input
3 3 2 
3 2 2
Sample Output
8 
-1
Source

2017绍兴市技能竞赛