Skip to content

Instantly share code, notes, and snippets.

@shashwata27
Created May 2, 2020 11:48
Show Gist options
  • Save shashwata27/ef42ff38dc6d6c9d06fd72675a053c1c to your computer and use it in GitHub Desktop.
Save shashwata27/ef42ff38dc6d6c9d06fd72675a053c1c to your computer and use it in GitHub Desktop.
For each of the four banks of the pool, he wants to have an equal number of tablechairs. There are three types of tablechairs set in the outlet. It is possible to buy a set of one tablechairs for R1 rupees, a set of two tablechairs for R2 rupees, and a set of three tablechairs for R3 rupees. The manager already has M tablechairs. What is the min…
testCases=int(input())
for y in range(testCases):
string=input()
Ch=0
index=string.find(" ")
M=int(string[:index])
string=string[index+1:]
index = string.find(" ")
R1 = int(string[:index])
string = string[index + 1:]
index = string.find(" ")
R2 = int(string[:index])
string = string[index + 1:]
R3=int(string)
#print(M,R1,R2,R3)
if M%4==0:
Ch=0
else:
for x in [1,2,3]:
if (M+x)%4==0:
Ch=x
if Ch==0:
print(0)
elif Ch==2:
l=[R1*2,R2]
l.sort()
print(l[0])
elif Ch==1:
print(R1)
else:
p=[3*R1,R1+R2,R3]
p.sort()
print(p[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment