Editorial for Computer Club Stickers


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.

English

There are N columns and there are N-1 many lines between these columns with length M so total length of vertical lines is (N-1)*M. There are M rows and there are M-1 lines between these rows with length N so total length of horizontal lines is (M-1)*N. In total, length of line to cut is N*(M-1)+M*(N-1).

Türkçe

N tane kolon var ve bu kolonlar arasında M uzunluğunda N-1 tane çizgi var yani dikey çizgilerin toplam uzunluğu (N-1)*M'dir. M sıra var ve bu sıralar arasında N uzunluğunda M-1 çizgi var yani yatay çizgilerin toplam uzunluğu (M-1)*N'dir. Toplamda, kesilecek çizgilerin uzunluğu N*(M-1)+M*(N-1)'dir.

Codes

C++
#include <iostream>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*(b-1)+b*(a-1)<<endl;
}
Python 3
n, m = map(int, input().split())
print(n*(m-1)+m*(n-1))