REGCLN - Editorial

PROBLEM LINK:

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

Author: iceknight1093
Tester: raysh07
Editorialist: iceknight1093

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

Chef cleans on days 10, 20, 30, \ldots, i.e. all multiples of 10.

Today is day number N. How many days is it till the next cleaning day?

EXPLANATION:

Let r denote the last digit of N. Equivalently, this is the remainder when N is divided by 10.

Then, 10-r days are needed to get to the next multiple of 10, and so this is the answer.

r can be obtained via the expression n % 10 in most programming languages.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
n = int(input())
print(10 - n%10)