407271: GYM102740 E Kario Mart

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Kario Marttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Sidra enjoys playing her friends in the new hottest racing game, Kario Mart, where little characters race around in shopping carts inside of a grocery store. Whoever makes it around the track and back to the cash register first wins! Sidra has gotten pretty good at Kario Mart but would really like to take her strategy to the next level by optimizing the speed and maneuverability of her shopping cart selection prior to the race.

Before beginning a race in Kario Mart, players select a grocery store map that they will all race in. All grocery stores are rectangular, so the players will select some map with dimensions $$$w\times h$$$. Once this choice is made, Sidra knows that the game logic then randomly generates a rectangular racetrack for the players to race on, which will fit within the $$$w\times h$$$ grocery store map and rest on its unit grid-lines, including possibly the outer-most grid-lines.

Once the selected grocery store map and randomly generated racetrack are fixed, then players choose their shopping carts. Sidra knows the importance of a well-tuned shopping cart to winning the race, so she would like to know how much of the race will consist of making sharp turns versus speeding down straightaways. Help Sidra make the best choice she can without knowing the exact location and dimensions of the generated racetrack.

Given the dimensions $$$w$$$ and $$$h$$$ of the selected grocery store map and the fact that all unique rectangles in the grocery store are equally likely to be generated as a racetrack for the game, determine the expected value of the perimeter of the racetrack! Note that a rectangular racetrack is uniquely defined by two ordered pairs $$$(x_1,y_1)$$$ and $$$(x_2, y_2)$$$ where $$$x_1<x_2$$$ and $$$y_1<y_2$$$ and $$$0\leq x_1,x_2 \leq w$$$ and $$$0\leq y_1,y_2\leq h$$$.

Input

The input consists of two space-separated integers, $$$w$$$ and $$$h$$$, representing the width and height of the selected grocery store map where $$$1\leq w,h \leq 1000$$$.

Output

Output the expected value of the perimeter of a rectangular race track, randomly generated within the grocery store. Round your answer to the nearest integer.

ExampleInput
2 2
Output
5

加入题单

算法标签: