Hackearth Solution
PROBLEM STATEMENT
Points: 30
Today Oz wants to make some money through his paintings. For painting, Oz has X white color pens, Y red color pens and Z green color pens. Their are 4 types of paintings he wants to make i.e.
- First kind of painting needs 3 white color pens.
- Second kind of painting needs 3 red color pens.
- Third kind of painting needs 3 green color pens.
- Fourth kind of painting needs 1 white, 1 red and 1 green color pen.
Oz wants to earn more money so he wants to make maximum number of paintings. Help Oz to find the maximum number of paintings he can make.
Input :
The first line contains the number of test cases T. Each test case consists of 3 integers X, Y and Z — the number of white, red and green color pens.
Output :
For each test case print the maximum number of paintings Oz can make.
Constraint :
1 ≤ T ≤ 10
0 ≤ X, Y, Z ≤ 109
Explanation
Oz can make 1 first kind, 1 second kind, 1 third kind and 1 fourth kind painting
Solution in python
import mathfor i in range(int(input())):nums = list(map(int,input().split()))x,y,z = numsa, x = divmod(x,3)b, y =divmod(y,3)c, z = divmod(z,3)if not x or not y or not z:print(a+b+c)else:print(a+b+c+math.gcd(math.gcd(x,y), z))
Comments
Post a Comment