OFFBY1 - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: iceknight1093
Tester: apoorv_me
Editorialist: iceknight1093

DIFFICULTY:

271

PREREQUISITES:

None

PROBLEM:

A calculator appends 1 to the result of every operation.
Given A and B, what does it print when asked for A+B?

EXPLANATION:

Print A+B followed by a 1.
This can be done in several ways:

  • As an integer, the resulting number is 10\cdot (A+B) + 1.
  • Otherwise, you can print A+B and then separately print a 1 after it - just make sure there’s no space between the two outputs.

TIME COMPLEXITY

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (Python)
a, b = map(int, input().split())
print(10*(a+b) + 1)