WEIRDVOL - Editorial

PROBLEM LINK:

Practice
Contest

Author: Riddhish Lichade
Tester: Ram Agrawal
Editorialist: Prathamesh Sogale

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Math

PROBLEM:

Given the volume of television, Meena wants to make it a multiple of 5. Find the minimum number of buttons he need to press to make the volume a multiple of 5.

EXPLANATION:

If the volume is less than 5 then we need to make it equal to 5, so in this case

ans=5-N.

Now the answers can be 0 or 1 or 2.
If N is already divisible by 5 then print 0.

If N%5==1 or N%5==4 then print 1, else print 2.

SOLUTIONS:

Setter's Solution
from sys import stdin
for _ in range(int(stdin.readline())):
    n=int(input())
    if(n<=5):
        print(5-n)
        continue
    ans=min((5-n)%5,n%5)
    print(ans)