Nội dung Bài tập
Mã:
Centipede's_Morning
Tên:
Centipede's Morning
Dạng thi:
acm
Thang điểm:
1 điểm
Giới hạn thời gian:
1 giây
Giới hạn bộ nhớ:
256 MB
Nguồn bài tập:
Ural Regional School Programming Contest 2011
Được tạo bởi:
thienph
Problem illustration
A centipede has 40 left feet and 40 right feet. It keeps a left slippers and b right slippers under its bed. Every morning the centipede puts on the slippers. It pokes its first left foot under the bed and puts on a random slipper, doing it in one second. If the slipper is left, the centipede passes to shoeing the second left foot. Otherwise, it takes off the slipper and puts it on any unshod right foot, spending one more second, so that it takes two seconds altogether to put on such a slipper. If there are no unshod right feet, the centipede throws the slipper to a corner of the room, also in one second, so that two seconds are spent altogether for this slipper. The process is continued until all the left feet are in left slippers. Then the centipede starts shoeing its right feet until all of them are shod.
Today the centipede has got out of bed on the wrong side, so it is preparing for the worst. How many seconds will it need for shoeing?

Input

The only line contains the integers a and b (40 ≤ a, b ≤ 100).

Output

Output the number of seconds the centipede will need for shoeing in the worst case.

Sample

inputoutput
40 40
120
Problem Author: Mikhail Rubinchik
Problem Source: Ural Regional School Programming Contest 2011
Problem illustration
Con rết có 40 chân trái và 40 chân phải. Con rết có a chiếc giày trái và b chiếc giày phải ở dưới giường. Mỗi buổi sáng con rết đều phải mang giày. Nó thả cái chân trái đầu tiên xuống dưới giường và đặt vào một chiếc giày ngẫu nhiên, và làm việc đó mất 1 giây. Nếu là giày trái, con rết tiếp tục mang giày cho cái chân trái thứ hai. Ngược lại, nó tháo giày ra và mang vào bất kì cái chân phải chưa có giày nào, mất thêm 1 giây nữa (vậy nên nó mất tổng công là 2 giây chỉ để mang một chiếc giày). Nếu như không có cái chân phải nào chưa có giày, con rết quăng chiếc giày vào góc phòng, việc này cũng mất thêm 1 giây nữa (vậy nên nó mất tổng công là 2 giây chiếc giày này). Khi tất cả chân trái đều được mang giày, con rết sẽ chuyển sang đế mang cho chân phải cho đến khi tất cả chân đểu được mang giày.
Hôm nay con rết đã xuống giường sai phía, nên mọi điều tồi tệ chuẩn bị xảy ra. Con rết sẽ tốn bao nhiêu giây để mang giày?

Input

Một dòng duy nhất chứa 2 số nguyên a và b (40 ≤ a, b ≤ 100).

Output

Xuất ra số giây con rết cần để mang giày trong trường hợp tệ nhất.

Sample

inputoutput
40 40
120
Problem Author: Mikhail Rubinchik
Problem Source: Ural Regional School Programming Contest 2011
* Cảm ơn sự đóng góp bản dịch của bạn anhvm.

    Quảng cáo
       Ngôn ngữ : 

       Theme : 
Mời bạn soạn code



		



      Ai có thể xem bài này : 

Thông tin



Phần thảo luận