Answer: 15 gallons and 35 gallons were consumed by first and second car respectively.
Explanation:
Since we have given that
Number of gallons of total gas consumption = 50
Number of total miles = 1700
Efficiency of first car = 20 miles per gallon
Efficiency of second car = 40 miles per gallon
Let the number of gallons consumed by first car be 'x'.
Let the number of gallons consumed by second car be '50-x'.
According to question, we get that

So, 50-x = 50-15 = 35 gallons.
Hence, 15 gallons and 35 gallons were consumed by first and second car respectively.