PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: iceknight1093
Tester: tabr
Editorialist: iceknight1093
DIFFICULTY:
347
PREREQUISITES:
None
PROBLEM:
Given A and B, print the difference between A+B and A\times B.
EXPLANATION:
As the statement says, simply print the difference between A+B and A\times B, i.e,
|(A+B)-(A\times B)|
In most languages, you can use the abs
function to do this.
Alternatively, you can use if
conditions to check which of A+B and A\times B is larger, and subtract the smaller from the larger.
TIME COMPLEXITY
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (Python)
a, b = map(int, input().split())
print(abs(a*b - (a + b)))