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 = gallons purchased, P = price per gallon with a 9 in the thousandths place.
If G is a whole number where 6 . 0 0 0 ≤ G ≤ 2 5 . 0 0 0 and 3 . 0 0 9 ≤ P ≤ 3 . 9 9 9 , how many pairs ( G , P ) will make the THIS SALE $ display a whole number of dollars?
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.
Since the whole dollar part of P doesn't matter, Here is G ∗ P = THIS SALE $ (rounded to the nearest cent)
7 . 0 0 ∗ 0 . 4 2 9 = 3 . 0 0
9 . 0 0 ∗ 0 . 8 8 9 = 8 . 0 0
1 1 . 0 0 ∗ 0 . 9 0 9 = 1 0 . 0 0
1 3 . 0 0 ∗ 0 . 7 6 9 = 1 0 . 0 0
1 7 . 0 0 ∗ 0 . 0 5 9 = 1 . 0 0
1 8 . 0 0 ∗ 0 . 3 8 9 = 7 . 0 0
1 8 . 0 0 ∗ 0 . 8 8 9 = 1 6 . 0 0
1 9 . 0 0 ∗ 0 . 5 7 9 = 1 1 . 0 0
2 1 . 0 0 ∗ 0 . 6 1 9 = 1 3 . 0 0
2 2 . 0 0 ∗ 0 . 4 0 9 = 9 . 0 0
2 2 . 0 0 ∗ 0 . 9 0 9 = 2 0 . 0 0
2 3 . 0 0 ∗ 0 . 7 3 9 = 1 7 . 0 0
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.
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.
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.
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 1 0 0 0 ) , { g , 6 , 2 5 } , { p , 3 0 0 9 , 3 9 9 9 , 1 0 } ] ] , 0 ≤ $#$1 ≤ 9 & ] ] ⟹ 1 2
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.
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 |
|
1 2 3 4 5 |
|
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.
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.
Problem Loading...
Note Loading...
Set Loading...
[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 gallons, and the per gallon price is P = n − 0 . 1 , for G , n ∈ N , 3 0 1 ≤ n ≤ 4 0 0 ; then the total cost G P = G n − 0 . 1 G and we want this to round to a multiple of 100.
Suppose 6 ≤ G ≤ 1 5 ; then 0 . 6 ≤ 0 . 1 G ≤ 1 . 5 . G n is a whole number, so if we want G P to round to a multiple of 100, then we need G n to end in 0 1 (or more technically, to be congruent to 1 ( m o d 1 0 0 ) .) This eliminates more than half the possible values of G , as no even number can have a multiple ending in 0 1 , and neither can 1 5 ; Thus the only possible values for G in this range are 7 , 9 , 1 1 and 1 3 ; we find multiples of these numbers ending in 0 1 . [This is not a random search; e.g. for G = 7 , we know that the ones digit of n has to be a 3 , then since 3 × 7 = 2 1 , the tens digit of n multiplied by 7 must end in an 8 , so the tens digit of n must be a 4 , which means n = 3 4 3 . The other values of n are found similarly.]
∙ ∙ ∙ ∙ G = 7 : G = 9 : G = 1 1 : G = 1 3 : n = 3 4 3 n = 3 8 9 n = 3 9 1 n = 3 7 7 ⇒ ⇒ ⇒ ⇒ G n = 2 4 0 1 G n = 3 5 0 1 G n = 4 3 0 1 G n = 4 9 0 1 ⟶ ⟶ ⟶ ⟶ 7 × $ 3 . 4 2 9 = $ 2 4 . 0 0 3 ≈ $ 2 4 . 0 0 9 × $ 3 . 8 8 9 = $ 3 5 . 0 0 1 ≈ $ 3 5 . 0 0 1 1 × $ 3 . 9 0 9 = $ 4 2 . 9 9 9 ≈ $ 4 3 . 0 0 1 3 × $ 3 . 7 6 9 = $ 4 8 . 9 9 7 ≈ $ 4 9 . 0 0
Note that for each value of G , there was only one possible value of n ; this is because all the values of G were relatively prime to 1 0 0 , so any other value of n would have to be at least 1 0 0 higher and thus outside our range.
Now suppose 1 6 ≤ G ≤ 2 5 ; then 1 . 6 ≤ 0 . 1 G ≤ 2 . 5 , which means we now need G n to end in 0 2 . This doesn't eliminate as many possible values of G as before, but we can still clearly eliminate 2 0 and 2 5 , and also 1 6 and 2 4 as no multiple of 4 can end in 0 2 . This leaves us six possible values for G , namely 1 7 , 1 8 , 1 9 , 2 1 , 2 2 and 2 3 . Note also that two of the values ( 1 8 , 2 2 ) have a common factor of 2 with 1 0 0 , so they will yield two possible values of n , which will differ by 5 0 .
∙ ∙ ∙ ∙ ∙ ∙ G = 1 7 : G = 1 8 : G = 1 9 : G = 2 1 : G = 2 2 : G = 2 3 : n = 3 0 6 n = 3 3 9 n = 3 8 9 n = 3 5 8 n = 3 6 2 n = 3 4 1 n = 3 9 1 n = 3 7 4 ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ G n = 5 2 0 2 G n = 6 1 0 2 G n = 7 0 0 2 G n = 6 8 0 2 G n = 7 6 0 2 G n = 7 5 0 2 G n = 8 6 0 2 G n = 8 6 0 2 ⟶ ⟶ ⟶ ⟶ ⟶ ⟶ ⟶ ⟶ 1 7 × $ 3 . 0 5 9 = $ 5 2 . 0 0 3 ≈ $ 5 2 . 0 0 1 8 × $ 3 . 3 8 9 = $ 6 1 . 0 0 2 ≈ $ 6 1 . 0 0 1 8 × $ 3 . 8 8 9 = $ 7 0 . 0 0 2 ≈ $ 7 0 . 0 0 1 9 × $ 3 . 5 7 9 = $ 6 8 . 0 0 1 ≈ $ 6 8 . 0 0 2 1 × $ 3 . 6 1 9 = $ 7 5 . 9 9 9 ≈ $ 7 6 . 0 0 2 2 × $ 3 . 4 0 9 = $ 7 4 . 9 9 8 ≈ $ 7 5 . 0 0 2 2 × $ 3 . 9 0 9 = $ 8 5 . 9 9 8 ≈ $ 8 6 . 0 0 2 3 × $ 3 . 7 3 9 = $ 8 5 . 9 9 7 ≈ $ 8 6 . 0 0
Thus we find that there are a total of 1 2 pairs of ( G , P ) which will make the display a whole number of dollars.