Editorial for 2157: Прямокутник


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Можна побачити, що усi клiтини, якi не знаходяться на межi, можна представити у виглядi прямокутника ~(n-2) \times (m-2)~.

Тож вiдповiддю буде ~n \times m-(n-2) \times (m-2) = 2 \times (n + m)-4~.

n = int(input())
m = int(input())
print((n + m) * 2 - 4)

Коментарі

Please read the guidelines before commenting.


Ще немає коментарів.