In Prime Country, "Prime Note" is used. The value of each Prime Note is the cube of any prime number. (For example, 8 Prime Dollar and 343 Prime Dollars are valid Prime Notes, as they can be expressed as and respectively)
A special law is designed in Prime Country, where the residents can only own limited types of Prime Note, based on their respective age levels, as stated below:
In Prime Country, no change will be given for those who pay more.
Mr Ong is 19 years old in the year 2020. One day, Mr Ong is standing a treat with his friend in a Doughnut Shop. Mr Ong will order before his friend. Without knowing the number of doughnuts his friend wants to order, what is the minimum number of doughnuts that Mr Ong must order, so that no matter how many doughnuts that his friend orders, Mr Ong can still pay in the exact amount of money with the Prime Notes he owns?
Note that Mr Ong's friend can order any number of doughnuts, including 0 if he has no appetite.
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.
Mr Ong can own 2 different values of Prime Notes, namely
First, we can find for the largest integer dollars N, such that no combination of the Prime Notes (the 8 and 27 Prime Notes) is worth exactly N Prime Dollars. Or, more commonly known as the Frobenius Number .
By applying the formula of Frobenius Number, If a and b are relatively prime, then N = g ( a , b ) = a b − a − b
In this case, N = g ( 8 , 2 7 ) = 8 × 2 7 − 8 − 2 7 = 1 8 1
Any number of doughnuts larger than 181 can be bought by Mr Ong with his Prime Notes. In the worst-case scenario, Mr Ong's friend has no appetite and he does not order any doughnut.
If Mr Ong orders 181 doughnuts, his friend order 0 doughnut, the total number of doughnuts will be 1 8 1 + 0 = 1 8 1 , which is the largest integer that cannot be expressed as any combination of 8 and 27. Therefore, any integer greater than 181 can be expressed as a combination of 8 and 27.
The minimum number of doughnuts that Mr Ong must order = 1 8 1 + 1 = 1 8 2