• Aucun résultat trouvé

Formally,we an dene the optimalrepresentationproblem as follows: givena set of D integer denominationse 1 <e 2 &lt

N/A
N/A
Protected

Academic year: 2022

Partager "Formally,we an dene the optimalrepresentationproblem as follows: givena set of D integer denominationse 1 <e 2 &lt"

Copied!
8
0
0

Texte intégral

(1)

What This Country Needs is an 18¢ Piee

Jerey Shallit

Department of Computer Siene

University of Waterloo

Waterloo, Ontario, Canada N2L 3G1

shallitgraeland.uwaterloo.a

November 8, 2002

Abstrat

We onsider sets of oin denominations whih p ermithange to b emade using as

fewoins as p ossible, on average,and explain why theUnited States shouldadopt an

18¢piee.

1 Introdution

Most businesses in the United States urrently make hange using four dierent typ es of

oins: 1¢ (ent), 1

5¢ (nikel),10¢ (dime),and 25¢ (quarter). For p eople who make hange

on a daily basis, it is desirable to make hange in as eÆient a manner as p ossible. One

riterion for eÆienyis to use the smallestnumb erof oins. For example,to make hange

for 30¢, one ould, at least in priniple, give a ustomer 30 1-ent oins, but most would

probably preferreeiving aquarter and a nikel.

Formally,we an dene the optimalrepresentationproblem as follows: givena set of D

integer denominationse

1

<e

2

< < e

D

and an integer N 0, we wish to express N as

a non-negative integer linear ombination N = P

1iD a

i e

i

suh that the numb er of oins

S = P

1iD a

i

isminimized. Inorder that everynumb eratuallyhave arepresentation,we

demandthat e

1

=1. If(a

1

;a

2

;:::;a

D

) istheD -tuple thatminimizesS,then wesay itis an

optimalrepresentation,and we dene opt(N;e

1

;e

2

;:::;e

D

):=S.

The optimal denominationproblem is to nd denominationsthat minimizethe average

ost of making hange. We assume that every amount of hange b etween 0¢ and 99¢ is

equallylikely.

2

Wethenask, whathoieofD denominationsminimizestheaveragenumb er

\Whatthis ountry needs is areally go o d ve-ent igar." T. R. Marshall (US Vie-President), New

YorkTribune,January4,1920.

1

Informally,a1-entoinisusuallyalled a\p enny",but thisusageisfrownedup onbynumismatists.

2

This assumption is probablyinaurate for several reasons, notleast b eing the fat that manyitems

have priesthatend inthedigit9. Also,Benford'slawmayplayarole;seeRaimi[7℄.

(2)

for D denominationsup to the limit L means determiningthe denominations e

1

;e

2

;:::;e

D

whihminimize

ost(L;e

1

;e

2

;:::;e

L ):=

1

L X

0i<L

opt (i;e

1

;e

2

;:::;e

D ):

For the urrent system, where (e

1

;e

2

;e

3

;e

4

) = (1;5;10;25), a simple omputation de-

termines that ost(100;1;5;10;25) =4:7. In other words, on average a hange-makermust

return 4:7 oins with everytransation.

Can wedo b etter? Indeedwean. Thereare exatlytwosetsof fourdenominationsthat

minimizeost (100;e

1

;e

2

;e

3

;e

4

);namely,(1;5;18;25) and(1;5;18;29). Bothhaveanaverage

ost of 3:89. We would therefore gain ab out 17% eÆienyin hange-making by swithing

to either of these four-oin systems. The rst system, (1;5;18;25), p ossesses the notable

advantage that we only need makeone smallalteration in the urrent system: replae the

urrent10¢ oin with a new 18¢ oin. This explains the titleof this artile.

Figure 1 givesthe optimaldenominationsof sizeD for 1D 7, and their asso iated

osts.

D (e

1

;:::;e

D

) ost(100;e

1

;:::;e

D )

1 (1) 49.5

2 (1;10) 9

(1;11)

3 (1;12;19) 5.15

4 (1;5;18;25) 3.89

(1;5;18;29)

5 (1;5;16;23;33) 3.29

6 (1;4;6;21;30;37) 2.92

(1;5;8;20;31;33)

7 (1;4;9;11;26;38;44) 2.65

Figure1: Optimaldenominationsfor hange-makingfor 1D 7 denominations

Althoughthesystem(1;5;18;25)wouldb esup eriortotheurrent(1;5;10;25)forhange-

making, it may b e diÆult to onvine p eople to aept the removal of the p opular dime.

Thusitmayb eworthwhileto onsideradierentquestion: what singledenominationould

we add to (1;5;10;25) to ahieve the maximumimprovement in ost? The unique answer

is 32¢; this improves ost(100;1;5;10;25) = 4:7 to ost(100;1;5;10;25;32 ) = 3:46. If we

also allowthe infrequently-used 50¢ pieeas alegitimatedenomination,then the maximum

improvementomes from adding an 18¢ piee;this improvesost(100;1;5;10;25;50) = 4:2

to ost(100;1;5;10;18;25 ;50) =3:18. Yetanotherreasonto addan18¢pieeto USoinage!

Otherountriesprovidedierentproblems. In Canada,theoin denominationsurrently

in wideirulation are 1¢, 5¢, 10¢, 25¢, 100¢ (alled a\lo onie" forthe lo on on the reverse),

and200¢(alleda\to onie"). Thesmallestdenominationof pap ermoneyinwideirulation

(3)

erage ost of makinghange inCanada is ost(500;1;5;10;25;10 0;20 0) =5:9. This an b e

b estimprovedbyadding an 83¢oin;wehaveost(500;1;5;10;25;83 ;100 ;200 ) =4:578. On

theotherhand,thenewsystemofEurosintro duedinEurop eprovidesoinsofdenomination

:01;:02;:05;:1;:2;:5;1,and2Euros. Forthissystemwehaveost(500;1;2;5;10;20;5 0;10 0;20 0) =

4:6. This anb eb estimproved(to averageost 3:92)by addingaoin ofdenomination1:33

or 1:37 Euros.

2 Greedy methods for hange-making

One nie feature of the urrent set of US denominations (1;5;10;25) is that the greedy

algorithmdeterminesthe representationwith the minimumnumb erof oins. Bythe greedy

algorithm, I mean the following pro edure: given a numb erN to b e represented as a non-

negativeintegerlinearombinationofdenominationse

1

<e

2

<<e

D

,takeasmanyopies

a

D

of thelargestdenominatione

D

as p ossible, so that a

D e

D

N. ThensetN :=N a

D e

D

and ontinue the pro edure with the remaining smaller denominations. Use of the greedy

algorithmprovides a simple,easily-rememb eredmetho d for makinghange. Not all sets of

denominations have the prop erty that the greedy metho d always determines the optimal

representation. For example, with denominations (1;7;10) the greedy algorithm gives the

representation 14=10+1+1+1+1, whereas 7+7 uses feweroins.

Unfortunately, none of the optimal sets of denominations in Figure 1 for D 3 give

optimal representations when used greedily. For example, when we try to greedily make

hangefor 24¢ usingthe system (1;12;19), weget 19+1+1+1+1+1, afar ryfrom the

optimalrepresentation12+12.

This suggests onsidering a variation on the optimal denominationproblem, where ost

is replaedby the analogous funtion gost, and weount only the ost of greedy represen-

tations. For the urrent systemwestill havegost (100;1;5;10;25) =4:7. Figure2 displays

the results for optimal sets of denominations. An asterisk denotes an optimalset for whih

the greedy representationis always an optimal representation.

We also might onsider what single denomination ould b e added to the urrent US

system (1;5;10;25) to b est improve the greedy ost. It turns out that adding either a 2¢-

pieeora3¢-pieeimprovesgost (100; )from4.7 to3.9,and thisistheb estp ossible1-oin

improvement. Itisinterestingto notethattheUSatuallyhada2¢-pieefrom1864to1873,

and two dierent 3¢-piees: one made in silverfrom 1851 to 1873, and one made innikel

from1865 to 1889.

3 Computational questions

So far we have fo used on systems partiular to the US, Canada, and Europ e, but a go o d

mathematiianwillwantmoregeneralresults. Letusexaminetheomputationalomplexity

of the problemswehave studied,and somerelated ones.

1. Supp ose we are givenan amountof hangeto make,say N,and asystem ofdenomi-

(4)

1 D 1 D

1 (1) 49.5

2 (1;10) 9

(1;11)

3 (1;5;22) 5.26

(1;5;23)

4 (1;3;11;37) 4.1

(1;3;11;38)

5 (1;3;7;16;40) 3.46

(1;3;7;16;41)

(1;3;7;18;44)

(1;3;7;18;45)

(1;3;8;20;44)

(1;3;8;20;45)

6 (1;2;5;11;25;62) 3.13

(1;2;5;11;25;63)

(1;2;5;13;29;64)

(1;2;5;13;29;65)

7 (1;2;5;8;17;27;63) 2.86

.

.

.

(27 other sets omitted)

.

.

.

(1;2;5;8;19;30;63)

(1;2;5;8;19;30;64)

(1;2;5;8;19;30;66)

(1;2;5;8;19;30;67)

Figure2: Optimaldenominationsfor greedy hange-making

nations, say 1=e

1

<e

2

<<e

D

. Howeasyis ittoomputeopt(N;e

1

;e

2

;:::;e

D

)or nd

an optimal representationN = P

1iD a

i e

i

, i.e.,one whih minimizes P

1iD a

i

?

The answer dep ends on how N and the e

i

are written down. If they are written in

ordinary deimalnotation, or in binary, then there is no fast algorithmknown to solve this

problem. In fat, it follows easily from results of Lueker [5℄ that this problem is NP-hard;

roughly sp eaking this means it is at least as hard as manyfamous ombinatorial problems,

suhasthetravellingsalesmanproblem,forwhihno p olynomial-timealgorithmisurrently

known.

If, on the other hand, N and the e

i

are represented in unary, then a simple dynami

programmingalgorithm(e.g.,[10 ℄)solvesthe optimalrepresentationprobleminp olynomial

time.

2. Supp ose we are given N and asystem ofdenominations. How easyis itto determine

if the greedy representationfor N isatually optimal? Kozen and Zaks[4℄have shown that

(5)

strongly suggests there is no eÆientalgorithmfor this problem.

3. Supp oseweare givenasystemofdenominations. Howeasyisittodeidewhetherthe

greedy algorithm always pro dues an optimal representation, for all values of N? It turns

out that this problem an b e solved eÆiently; this surprising result is due to Pearson [6℄.

Sine Pearson's result app eared only inan obsuretehnialrep ort, we give afew details.

Supp ose the greedyalgorithmforthe systemof denominations1=e

1

<e

2

< <e

D is

not always optimal. Pearson showed there existintegers i;j with 1 j i <D suh that

the minimalrepresentationof the minimalounterexampleisof the form

0e

1

+0e

2

++0e

j 1 +(a

j +1)e

j +a

j+1 e

j+1

++a

D e

D

;

where the greedy representationof e

i+1 1 is

a

1 e

1 +a

2 e

2

++a

D e

D :

This gives the following algorithmfor nding the smallest numb ersuh that the greedy

algorithmfails to b e optimal(or 1 ifno suh numb er exists):

PearsonTest(e

1

;e

2

;:::;e

D )

m :=1

for j :=1to D 1do

for i:=j to D 1do

Let P

1iD a

i e

i

b e the greedy representationof e

i+1 1

a

j :=a

j +1

for k:=1to j 1 do

a

k :=0

r:=

P

1iD a

i e

i

if r<m then

Let P

1iD b

i e

i

b e the greedy representationof r

if P

1iD b

i

>

P

1iD a

i then

m :=r

return(m)

(Herethe sop e ofthe lo ops is denotedby indentation.) It iseasyto seethat this algorithm

p erformsO (n 3

)arithmetiop erations on numb ersof sizeO (e

D ).

4. Supp ose we are givenN and a systemof denominations. How easy is it to ompute

ost(N;e

1

;e

2

;:::;e

D

)? Sine

opt (N;e

1

;e

2

;:::;e

D

)=(N +1)ost (N+1;e

1

;e

2

;:::;e

D

) Nost (N;e

1

;e

2

;:::;e

D );

any algorithm to omputeost would also providean algorithm to ompute opt. It follows

that omputing ost is NP-hard underTuring redutions.

(6)

minimizesthe averageost of makinghangefor allamounts from0to L 1? I don't know

the omputationalomplexityof this problem,but itseems quitehard. The data presented

in Figure 1 were omputed using a brute-fore enumeration of p ossibilities, but with some

triks to sp eed up the omputation.

6. A relatedproblemis the Frob enius problem. Hereweare givena setof D denomina-

tionse

1

<e

2

<<e

D

with gd(e

1

;e

2

;:::;e

D

)=1,andwewantto ndthe largestinteger

N whih annot b e expressed in the form P

1iD a

i e

i

with the a

i

non-negative integers.

Thereisahugeliteratureonthis problem(see,for example,Guy[2,pp.113{114℄), butonly

reently have researhers onsidered its omputational omplexity. Kannan [3℄ gave an al-

gorithmforthe Frob eniusproblemthatruns inp olynomialtimeif the dimensionD is xed.

On the other hand, Ramrez-Alfonsn [8℄ has shown that the general Frob enius problem is

NP-hard.

7. Another related problem is the p ostage stamp problem. There are two avors. The

\lo al" problem asks, givena set of D denominations1= e

1

< e

2

< < e

D

and a b ound

h, whatisthe smallestintegerN whihannot b erepresentedinthe formN = P

1iD a

i e

i

where the a

i

are non-negative integers and P

1iD a

i

h? In the \global" version,we are

given D and h and want to nd the set of denominations that maximizes N. There is a

large literatureon these twoproblems(see Guy[2, pp. 123{127℄), with muheort devoted

to ndingeÆientalgorithms forsmall D .

However, I reently showed [9℄ that the lo al p ostage stamp problem is NP-hard under

Turing redutions, and that there is ap olynomial-timealgorithmfor everyxedD .

4 Asymptoti results

Nowwe turn to someasymptoti estimates.

Let optost(L;D ) denote the minimum value of ost(L;e

1

;e

2

;:::;e

D

) over all suitable

values of e

1

;:::;e

D

. Can we nd go o d upp er and lower b oundson optost (L;D )?

One way to nd an upp er b ound is as follows: let k =dL 1=D

e, and dene e

i

= k i 1

for

1 i D . In this ase, the greedy algorithm always nds the optimal representation for

any N, and it turns out to b e the base-k expansionof N. Letting s

k

(N) denotethe sumof

the digits in the base-k expansionof N, we nd

ost(L;e

1

;e

2

;:::;e

D

)=gost (L;e

1

;e

2

;:::;e

D )=

1

L X

0iL 1 s

k (i):

Hene

optost(L;D ) 1

L S

dL 1=D

e

(L) (1)

where S

k

(N):=

P

0i<N s

k (i).

Nowthe quantity S

k

(N) has a long history; itis known that

S

k (N)=

k 1

2logk

NlogN +NF

k

logN

logk

; (2)

(7)

k

example,[1℄. Combining(1) and (2), we obtainthe upp er b ound

optost (L;D ) D

2 L

1=D

:

Furthermore, using the identity

S

k

(kN +a)=kS

k (N)+

k(k 1)N

2

+as

k (N)+

a(a 1)

2

oneanomputeS

k

(N)intimep olynomialinthenumb erofdigitsinkandN. Thisprovides

a fastway to ompute the upp er b ound (1).

For alowerb ound,onemayreasonasfollows: xasetofDdenominationse

1

;e

2

;:::;e

D ,

and onsiderthe numb er of dierent D -tuples (a

1

;a

2

;:::;a

D

) suh that P

1iD a

i

k. A

simple ombinatorial argument shows that this numb er is D +k

D

. Now if D +k

D

L=2, it

follows that for at least L=2 hoies of N, 1 N L, any representation for N must use

at least k+1oins, and heneoptost (L;D ) 1

2

(k+1). Now D +k

D

(k +D )

D

D !

;if D isxed

and L!1, this gives the lowerb ound of optost (L;D )=(L 1=D

).

5 Aknowledgments

I obtained the results in Tables 1 and 2 inOtob er 1999. Erik Demainekindly p ointed out

that similarresults werep osted to the Usenetnewsgroup si.mathby Jery Johnston and

BillKinnersleyin April2000.

I thank Troy Vasiga, Ming-wei Wang, and Erik Demainefor their helpfulomments.

Referenes

[1℄ H. Delange. Sur la fontion sommatoirede la fontion \somme des hires". Enseign.

Math. 21 (1975), 31{47.

[2℄ R. K.Guy. Unsolved Problems in Number Theory. Springer-Verlag, 2nd edition, 1994.

[3℄ R.Kannan. Lattietranslatesofap olytop eandtheFrob eniusproblem. Combinatoria

12 (1992), 161{177.

[4℄ D. Kozen and S. Zaks. Optimal b ounds for the hange-making problem. Theoret.

Comput. Si. 123 (1994), 377{388.

[5℄ G.S.Lueker.TwoNP-ompleteproblemsinnonnegativeintegerprogramming.Tehni-

al Rep ort TR-178, Computer Siene Lab oratory, Departmentof Eletrial Engineer-

ing, PrinetonUniversity,Marh1975.

[6℄ D. Pearson. A p olynomial-time algorithm for the hange-making problem. Tehnial

Rep ort TR 94-1433, Department of Computer Siene, Cornell University, June 1994.

Availablefromhttp://iteseer.nj.ne.om/pearson94polynomialtime.html.

(8)

[8℄ J.L.Ramrez-Alfonsn.ComplexityoftheFrob eniusproblem.Combinatoria16(1996),

143{147.

[9℄ J.Shallit. The omputationalomplexityof thelo alp ostagestampproblem. SIGACT

News 33(1) (2002), 90{94.

[10℄ J. W. Wright. The hange-makingproblem. J. Asso. Comput.Mah. 22 (1975), 125{

128.

Références

Documents relatifs

[r]

[r]

Homework problems due December 10, 2014.. Please put your name and student number on each of the sheets you are

Then it seems likely that for β &gt; 1/2 there is a Ricci flat K¨ ahler metric on the complement of the curve with standard cone singularities of cone angle 2πβ away from the origin,

First introduced by Faddeev and Kashaev [7, 9], the quantum dilogarithm G b (x) and its variants S b (x) and g b (x) play a crucial role in the study of positive representations

James presented a counterexample to show that a bounded convex set with James’ property is not necessarily weakly compact even if it is the closed unit ball of a normed space.. We

The critical case where p = −n of the L p Minkowski problem is called the centro-affine Minkowski problem, which describes the centro-affine surface area measure.. This problem

all the q~k correspond to finite energy states, i.e.. Our theorem says that states with non-zero initial decay rate could be found among infinite energy states1). What