#P2660. zzc 种田

    ID: 3478 远端评测题 1000ms 125MiB 尝试: 2 已通过: 2 显示难度普及− 上传者: 标签>数学贪心递归洛谷原创

zzc 种田

Background

Maybe in the future zzc will go farming.

Problem Description

The field is a huge rectangle. However, zzc can plant only one square at a time, and the stamina cost for planting a square is the square’s perimeter. Areas that have already been planted cannot be planted again. zzc is lazy and wants to save stamina to hang out with girls, so he wants to finish planting the entire field with the least stamina. Find the minimum stamina cost.

Input Format

Two positive integers x,yx, y, representing the length and width of the field.

Output Format

Output the minimum stamina cost.

1 10
40
2 2 
8

Hint

Constraints: 1x,y10161 \le x, y \le 10^{16}.

Translated by ChatGPT 5