Gas

In the USA gasoline is always priced to the nearest thousandth of a dollar per gallon and the price always has a 9 in the thousandths place.

When gasoline costs $3.429 per gallon and you buy 7.000 gallons exactly, the display will look like the picture.

G = G = gallons purchased, P = P= price per gallon with a 9 in the thousandths place.

If G G is a whole number where 6.000 G 25.000 6.000\le G\le25.000 and 3.009 P 3.999 3.009\le P \le 3.999 , how many pairs ( G , P ) (G,P) will make the THIS SALE $ display a whole number of dollars?


The answer is 12.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

5 solutions

Zico Quintina
Jul 10, 2018

[Please note this solution was written when the category of the problem was Number Theory.]

To begin with, we note that any price with a 9 in the thousands place can be thought of as 0.001 less than a "normal" dollar amount with the usual two decimal places; e.g. $3.429 = $3.43 - $0.001, $3.799 = $3.80 - $0.001, etc. To simplify our notation, we will convert the prices to cents, so our two previous examples would now be $3.429 = 343¢ - 0.1¢ and $3.799 = 380¢ - 0.1¢. (For the remainder of this solution prices will be in cents unless accompanied by the $ sign.)

If we're purchasing G G gallons, and the per gallon price is P = n 0.1 P = n - 0.1 , for G , n N , 301 n 400 G,n \in \mathbb{N}, 301 \le n \le 400 ; then the total cost G P = G n 0.1 G GP = Gn - 0.1G and we want this to round to a multiple of 100.

Suppose 6 G 15 6 \le G \le 15 ; then 0.6 0.1 G 1.5 0.6 \le 0.1G \le 1.5 . G n Gn is a whole number, so if we want G P GP to round to a multiple of 100, then we need G n Gn to end in 01 01 (or more technically, to be congruent to 1 ( m o d 100 ) 1 \pmod{100} .) This eliminates more than half the possible values of G G , as no even number can have a multiple ending in 01 01 , and neither can 15 15 ; Thus the only possible values for G G in this range are 7 , 9 , 11 7, 9, 11 and 13 13 ; we find multiples of these numbers ending in 01 01 . [This is not a random search; e.g. for G = 7 G = 7 , we know that the ones digit of n n has to be a 3 3 , then since 3 × 7 = 21 3 \times 7 = 21 , the tens digit of n n multiplied by 7 7 must end in an 8 8 , so the tens digit of n n must be a 4 4 , which means n = 343 n = 343 . The other values of n n are found similarly.]

G = 7 : n = 343 G n = 2401 7 × $ 3.429 = $ 24.003 $ 24.00 G = 9 : n = 389 G n = 3501 9 × $ 3.889 = $ 35.001 $ 35.00 G = 11 : n = 391 G n = 4301 11 × $ 3.909 = $ 42.999 $ 43.00 G = 13 : n = 377 G n = 4901 13 × $ 3.769 = $ 48.997 $ 49.00 \begin{array}{rlrclcl} \bullet & G = \ \ 7: & n = 343 & \Rightarrow & Gn = 2401 & \longrightarrow & \ \ 7 \times \$3.429 = \$24.003 \approx \$24.00 \\ \bullet & G = \ \ 9: & n = 389 & \Rightarrow & Gn = 3501 & \longrightarrow & \ \ 9 \times \$3.889 = \$35.001 \approx \$35.00 \\ \bullet & G = 11: & n = 391 & \Rightarrow & Gn = 4301 & \longrightarrow & 11 \times \$3.909 = \$42.999 \approx \$43.00 \\ \bullet & G = 13: & n = 377 & \Rightarrow & Gn = 4901 & \longrightarrow & 13 \times \$3.769 = \$48.997 \approx \$49.00 \end{array}

Note that for each value of G G , there was only one possible value of n n ; this is because all the values of G G were relatively prime to 100 100 , so any other value of n n would have to be at least 100 100 higher and thus outside our range.

Now suppose 16 G 25 16 \le G \le 25 ; then 1.6 0.1 G 2.5 1.6 \le 0.1G \le 2.5 , which means we now need G n Gn to end in 02 02 . This doesn't eliminate as many possible values of G G as before, but we can still clearly eliminate 20 20 and 25 25 , and also 16 16 and 24 24 as no multiple of 4 4 can end in 02 02 . This leaves us six possible values for G G , namely 17 , 18 , 19 , 21 , 22 17, 18, 19, 21, 22 and 23 23 . Note also that two of the values ( 18 , 22 18, 22 ) have a common factor of 2 2 with 100 100 , so they will yield two possible values of n n , which will differ by 50 50 .

G = 17 : n = 306 G n = 5202 17 × $ 3.059 = $ 52.003 $ 52.00 G = 18 : n = 339 G n = 6102 18 × $ 3.389 = $ 61.002 $ 61.00 n = 389 G n = 7002 18 × $ 3.889 = $ 70.002 $ 70.00 G = 19 : n = 358 G n = 6802 19 × $ 3.579 = $ 68.001 $ 68.00 G = 21 : n = 362 G n = 7602 21 × $ 3.619 = $ 75.999 $ 76.00 G = 22 : n = 341 G n = 7502 22 × $ 3.409 = $ 74.998 $ 75.00 n = 391 G n = 8602 22 × $ 3.909 = $ 85.998 $ 86.00 G = 23 : n = 374 G n = 8602 23 × $ 3.739 = $ 85.997 $ 86.00 \begin{array}{rlrclcl} \bullet & G = 17: & n = 306 & \Rightarrow & Gn = 5202 & \longrightarrow & 17 \times \$3.059 = \$52.003 \approx \$52.00 \\ \bullet & G = 18: & n = 339 & \Rightarrow & Gn = 6102 & \longrightarrow & 18 \times \$3.389 = \$61.002 \approx \$61.00 \\ & & n = 389 & \Rightarrow & Gn = 7002 & \longrightarrow & 18 \times \$3.889 = \$70.002 \approx \$70.00 \\ \bullet & G = 19: & n = 358 & \Rightarrow & Gn = 6802 & \longrightarrow & 19 \times \$3.579 = \$68.001 \approx \$68.00 \\ \bullet & G = 21: & n = 362 & \Rightarrow & Gn = 7602 & \longrightarrow & 21 \times \$3.619 = \$75.999 \approx \$76.00 \\ \bullet & G = 22: & n = 341 & \Rightarrow & Gn = 7502 & \longrightarrow & 22 \times \$3.409 = \$74.998 \approx \$75.00 \\ & & n = 391 & \Rightarrow & Gn = 8602 & \longrightarrow & 22 \times \$3.909 = \$85.998 \approx \$86.00 \\ \bullet & G = 23: & n = 374 & \Rightarrow & Gn = 8602 & \longrightarrow & 23 \times \$3.739 = \$85.997 \approx \$86.00 \\ \end{array}

Thus we find that there are a total of 12 \boxed{12} pairs of ( G , P ) (G,P) which will make the display a whole number of dollars.

Jeremy Galvagni
Jul 8, 2018

Since the whole dollar part of P P doesn't matter, Here is G P = G*P= THIS SALE $ (rounded to the nearest cent)

7.00 0.429 = 3.00 7.00*0.429=3.00

9.00 0.889 = 8.00 9.00*0.889=8.00

11.00 0.909 = 10.00 11.00*0.909=10.00

13.00 0.769 = 10.00 13.00*0.769=10.00

17.00 0.059 = 1.00 17.00*0.059=1.00

18.00 0.389 = 7.00 18.00*0.389=7.00

18.00 0.889 = 16.00 18.00*0.889=16.00

19.00 0.579 = 11.00 19.00*0.579=11.00

21.00 0.619 = 13.00 21.00*0.619=13.00

22.00 0.409 = 9.00 22.00*0.409=9.00

22.00 0.909 = 20.00 22.00*0.909=20.00

23.00 0.739 = 17.00 23.00*0.739=17.00

I just made a spreadsheet and searched. These are all from fractions that have a number close to 9 in the thousandths place of the decimal, but since it's hard to say how close it needs to be, it was hard to search that way. For example, 3/7=6/14=.42857 is close enough for 7 gallons but not for 14. 0.429=7=3.003 rounds down, 0.429*14=6.006 rounds up.

Jeremy, small typo in the fourth line, it should be 13.00 * 0.769; I only noticed because I used your values to double-check mine! Can you double-categorize the problem? =) I didn't realize until after I posted the solution that the category had changed. Oh, well.

zico quintina - 2 years, 11 months ago

Log in to reply

Fixed, thanks.

As far as the category... I should have waited to see if someone had a better analytic solution before changing it. Yours is really nice.

Jeremy Galvagni - 2 years, 11 months ago

Log in to reply

Thanks. No worries about the category, I could probably use a boost to my CompSci level anyway, it's pathetically low at the moment.

zico quintina - 2 years, 11 months ago

I made the following assumptions: the pump delivers gasoline in pulses of one-thousandth of a gasoline and therefore the gasoline amount is exact, the computations within the pump are done to the mill ($0.001) and that 5/4 rounding occurs in the displayed price amount. The last assumption is reasonable as the example in the picture is for 24003 mills.

Length [ Select [ Flatten [ Table [ ( ( g p + 5 ) m o d 1000 ) , { g , 6 , 25 } , { p , 3009 , 3999 , 10 } ] ] , 0 $#$1 9 & ] ] 12 \text{Length}[\text{Select}[\text{Flatten}[\text{Table}[((g\ p+5) \bmod 1000),\{g,6,25\},\{p,3009,3999,10\}]],0\leq \text{\$\#\$1}\leq 9\&]] \Longrightarrow 12

There would be 201 combinations if the final digit of the gasoline were all possible digits. I am old enough to remember gasoline prices that were so.

A brief description of the computation: compute fractional dollar amount of each combination with the addition of 5 mills to cause the cents portion to be correctly 5/4 rounded, structure the result as a single list (Flatten), select those elements of the list that are 0 to 9 mills and count them.

Mykyta Shvets
Jul 11, 2018

Since this problem is marked as Computer Science , my solution uses some Python. The program runs for just 0.1s!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
pairs = set()

# For all possible G and P
for G in range(6, 26):
    for P in [3.009 + n / 100 for n in range(0, 100)]:  # 3.009 - 3.999
        # If it's a whole number, add it to the list
        if round(G * P, 2) == round(G * P, 0):
            pairs.add((G, P, round(G * P, 2)))

print(len(pairs))
print(pairs)

1
2
3
4
5
# Output:
12
{(11, 3.909, 43.0), (7, 3.429, 24.0), (19, 3.579, 68.0), (13, 3.769, 49.0), 
(18, 3.389, 61.0), (22, 3.409, 75.0), (21, 3.619, 76.0), (22, 3.909, 86.0), 
(9, 3.889, 35.0), (17, 3.059, 52.0), (18, 3.889, 70.0), (23, 3.739, 86.0)}

I also used an Excel spreadsheet to solve it. It may be more appropriate to change it to Computer Science problem instead of Number Theory.

  • The spreadsheet range is A1:U101 (cell A1: 12 and cell A101: 3.999).
  • Formulas in the range B2:U101 are similar to that in cell B2: =IF(B$1 * $A2-INT(B$1 * $A2)<0.01, 1, 0) . This means that if the fractional part of product G P GP is less than 0.01 assign 1 as the output of the cell otherwise assign 0.
  • Then in cell A1: =SUM(B2:U101) . This sum up all the cases and the result is 12 \boxed{12} .

You should notice that the 1s are highlighted in red. I used the conditional formatting ( Conditional Formatting; Highlight Cells Rules; Equal To...; 1 ) so that it highlighted all cells contain 1 as output.

I didn't know if a simple spreadsheet counted as computer science - though yours is much more clever than mine. I also didn't know if I could change the category. I turns out I can so comp sci it is.

Jeremy Galvagni - 2 years, 11 months ago

Log in to reply

It is quite okay.

Chew-Seong Cheong - 2 years, 11 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...