TAXES - Editorial

PROBLEM LINK:

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

Author: Kanhaiya Mohan
Tester: Tejas Pandey
Editorialist: Nishank Suresh

DIFFICULTY:

276

PREREQUISITES:

None

PROBLEM:

A tax of 10 rupees is deducted if one’s income is strictly larger than 100. Given an income of X, what is the final amount of money you receive?

EXPLANATION:

There are two cases, which can be checked with an if condition.

  • If X \leq 100, then nothing is deducted. So, the final amount is just X
  • Otherwise, X \gt 100, and rupees 10 is deducted. So, the final amount is X - 10.

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    x = int(input())
    if x > 100:
        x -= 10
    print(x)
1 Like