You are on page 1of 16

The Chinese Restaurant Approach to Integer Representation Problems

by Harold Reiter University of North Carolina Charlotte

We are given a set G of generators and a process P for producing integers from the members of G. Actually well let G be a set, a multiset, or a sequence. G can be nite or innite. Each choice of G and P gives rise to a set R of results. Well see how varying G and P gives rise to many dierent types of problems.

. . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Some examples of Gs are: G1 = {100 , 101 , 102 , . . .}, the powers of 10. G2 = {2, 3, 5, 7, . . .}, the primes. G3 = {1, 2, 3, 4, . . .}, the positive integers. G4 = {1, 2, 4, 8, . . .}, the non-negative integral powers of 2. G5 = {1, 3, 9, 27, . . .}, the non-negative integral powers of 3.

G6 = {1, 2, 4, 8, . . .}, the integral powers of 2. G7 = {p, q }, any two distinct primes (or relative primes). G8 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, the integers from 1 to 11. G9 = {1, 2, 3, 5, 8, 13, . . .}, the Fibonacci numbers. G10 = {1, 5, 10, 25, 50, 100}, the values in cents of US coins. G11 = {1, 4, 9, 16, 25, }, the perfect squares. G12 = {1, 2, 6, 24, . . .}, the factorials of positive integers. We will also allow G to be a multiset, that is, an object which can have multiple membership, but which is unchanged by a rearrangement of its members. For example {1, 1, 2, 2, 3, 3, 3} is a multiset which is not the same as {1, 2, 3}, but which is the same as {1, 1, 3, 2, 3, 3, 2}. In this case the three instances of the 3 are considered distinct. We can match these generating sets Gi with generating processes Pj . Some examples we will use are: P1 : r = x1 + x2 + + xn ,

where n is arbitrary and the xi are all distinct members of G. In other words, the set R of results of applying P to G is given by R = {r = x1 + x2 + + xn : n is arbitrary and the xi are all distinct members of G} P2 : r = d1 x1 + d2 x2 + + dn xn ,

where n is arbitrary, the xi are all distinct members of G, and the di are decimal digits. P3 : r = a 1 x1 + a 2 x2 + + a n xn ,

where n is arbitrary, the xi are all distinct members of G, and the ai are arbitrary positive integers. For example, we might insist that the ai belong to a given set C . P4 : r = a 1 x1 + a 2 x2 + + a n xn ,

where n is arbitrary, the xi are all distinct members of G, and the ai all belong to some prescribed subset C of the positive integers. This generalizes all the examples below.

For the next process, we no longer take integer conbinations to get members of R. We allow instead any arithmetic operations. P5 : r = x1 21 x2 22 2n1 xn ,

where n is arbitrary, 2i {+, , , } for each i, the xi are all distinct members of G, and parentheses are inserted so that the expression is unambiguous. For all the examples above, note that the number of summands is arbitrary. For those below, we x n and require that the expression have exactly n members of G. In this case it makes a dierence whether 0 is included in the set C of allowed coecients. If 0 is included, then expressions could eectively have fewer than n members of G. P6 (n) : r = x1 x2 xn ,

where n is xed and the xi are all distinct members of G. P7 (n) : r = x1 + x2 + + xn ,

where n is xed and the xi are all distinct members of G. Of course, these Pi could be generalized in the same way that we did for those with the arbitrary n, simply by requiring the coecients be members of some set C . Then there is the n-xed analog of P5 . P8 (n) : r = x1 21 x2 22 2n1 xn ,

where n is xed, 2i {+, , , } for each i, the xi are all distinct members of G, and parentheses are inserted so that the expression is unambiguous. What questions do we ask about these Gs and P s? Is the set R of numbers generated nite or innite? 1. Suppose R is innite.

(a) Is R the set of all positive integers? If not, what is the smallest omitted (positive integer) value? (b) Is each member of R represented uniquely? If not, how many ways can the integer n be represented? (c) Is there a nice algorithm for nding the nth one? (d) Is the complement of R nite? If so, what is the largest integer not in R? 2. Suppose R is nite. (a) What is the cardinality of R? (b) Is representation unique? (c) What is the largest member of R? (d) What is the smallest positive integer not in R? There is another type of question which ts very nicely in this framework. Suppose we are given the P and the R. We can ask questions about the sets, lists, or multisets G which result in R when P is applied. For example, problems 4 and 7 below are of this type. Here are some sample problems: 1. Problem 7, 1986 AIME. The increasing sequence 1, 3, 4, 9, 10, 12, 13, . . . consists of those integers which are powers of three or sums of distinct powers of 3. Find the 100th term of the sequence (where 1 is the 1st term, 3 is the 2nd term, and so on). 2. NC-SC ARML Training Session, 1994. How many numbers can be expressed as a sum of four distinct members of the set {17, 21, 25, 29, 33, 37, 41}? 3. The Postage Stamp Problem An unlimited supply of postage stamps of denominations p and q are

available, where p and q are relatively prime. What is the largest amount of postage that cannot be produced using these stamps? 4. The Balance Pan Problem. Given a nite set {w1 , w2 , w3 , . . . , wn }, and a two-pan balance, what is the largest number of weights which can be determined by the wi ? How should the values w1 , w2 , w3 , . . . , wn be selected to minimize the number of duplicated values? 5. McNuggets Problem. Chicken McNuggets come in packages of size 6, 9 and 20. What is the largest number of McNuggets which cannot be purchased? 6. How many integers can be obtained as a sum of two or more of the numbers 1, 3, 5, 10, 20, 50, 82? (Alan Tuckers Applied Combinatorics, problem 40, page 179.) 7. If pairs of distinct elements of the set S are added, the following ten numbers are obtained: 1967, 1972, 1973, 1974, 1975, 1980, 1983, 1984, 1989, 1991. What are the elements of S ? (USAMTS, 1995) 8. Use each of the nine digits 1, 2, 3, 4, 5, 6, 7, 8, and 9 exactly twice to form distinct prime numbers whose sum is as small as possible. 9. How many numbers can be obtained as the product of two or more of the numbers 3, 4, 4, 5, 5, 6, 7, 7, 7? (Alan Tuckers Applied Combinatorics, problem 34, page 179.) 10. Brackets can be inserted into the expression 1 2 3 4 in various ways. For example, (1 2) (3 4) equals 2/3 whereas 1 ((2 3) 4) equals the whole number 6. Similarly, brackets can be inserted into 1 2 3 4 5 6 7 8 9 10 11 to produce a large collection

of answers, many of which are integers. What do you get if you divide the largest of these integers by the smallest of these integers? (London Times Brainteaser #1696). 11. How many of the rst 100 positive integers are expressible as a sum of three or fewer members of the set {30 , 31 , 32 , 33 , 34 } if we are allowed to use the same power more than once. For example, 5 can be represented, but 8 cannot. (1991 State Math Contest of North Carolina.) 12. How many integers can be expressed as a sum of two or more dierent members of the set {0, 1, 2, 4, 8, 16, 31}? (1994 UNC Charlotte Contest.) 13. In a standard inx calculator, unparenthesized expressions are evaluated as follows: (a) Multiplications and divisions are done rst, starting at the left and moving to the right. (b) Additions and subtractions are done, again moving from left to right.
2 . How many dierent values are For example, 1 2 3 4 is 3 3 possible if each is replaced by one of +, , , or in the expression 1 1 1 1 1 1 1 1? (1987 State Math Contest of North Carolina.)

14. The number 113 can be expressed as a sum of multiples of powers of 3. In fact, there exist integers a0 , a1 , a2 , a3 , a4 , such that 0 ai 2 and 113 = a4 (3)4 + a3 (3)3 + a2 (3)2 + a1 (3)1 + a0 (3)0 . Find the value of a0 + a1 + a2 + a3 + a4 . (1990 State Math Contest of North Carolina.) 15. John has 2 pennies, 3 nickels, 2 dimes, 3 quarters, and 8 dollars. For how many dierent amounts can John make an exact purchase?

16. Show that 1997 can be written in the form 12 22 3 2 k 2 for some positive integer k . Next show that every positive integer can be written in this way. (Paul Erd os) 17. Do there exist positive integers N and M such that every positive ingerger larger than M can be written as the sum of at most N distinct Fibonacci numbers? (Leo Schneider) SOLUTIONS 1. Problem 7, 1986 AIME. The increasing sequence 1, 3, 4, 9, 10, 12, 13, . . . consists of those integers which are powers of three or sums of distinct powers of 3. Find the 100th term of the sequence (where 1 is the 1st term, 3 is the 2st term, and so on). Solution. Let G be the powers of 3. Let P be the process which allows addition of distinct members of G. The elements of R are representable in ternary using just the digits 0 and 1. So they all look like binary representations. The ordering of the elements of R is the same as they would be ordered in binary. Therefore the 100th one is the one whose ternary representation is the binary representation of 100. Since

100 = 64 + 32 + 4 = 2 6 + 25 + 22 = 1 26 + 1 25 + 0 2 4 + 0 2 3 + 1 2 2 + 0 2 1 + 0 2 0 = 11001002 , it follows that the 100th member of R is 36 +35 +32 = 729+243+9 = 981.

2. NC-SC ARML Training Session, 1994. How many numbers can be expressed as a sum of four distinct members of the set {17, 21, 25, 29, 33, 37, 41}? Solutions. Let G = {17, 21, 25, 29, 33, 37, 41} and let P be P7 (4). Each member of G is one more than a multiple of four. Therefore, any sum of four of them is a multiple of 4. The smallest such number is 17+21+25+29 = 92 and the largest is 29+33+37+41 = 140 and all the multiples of 4 between them are obtainable. There 92 are 1404 + 1 = 48 + 1 = 13 such numbers. 4 We transform the problem into a simpler one. Because 17 = 4 4 + 1, 21 = 4 5 + 1, . . . , 41 = 4 10 + 1, it makes sense to set up a correspondance between R and the set of numbers generated by {4, 5, 6, 7, 8, 9, 10} using P7 (4) OR between R and those numbers generated by {3, 2, 1, 0, 1, 2, 3} using P7 (4). The set R in this case is just {6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6}, which has 13 members. There are 7 = 35 ways to choose four elements from the seven4 member set G. But there is some duplication. The table below shows the number of ways Tn to write n, (alternatively 116n + 4n) as a sum of four members of {3, 2, 1, 0, 1, 2, 3} (alternatively, {17, 21, 25, 29, 33, 37, 41}). n -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 Tn 1 1 2 3 4 4 5 4 4 3 2 1 1 3. The Postage Stamp Problem An unlimited supply of postage stamps of denominations p and q are available, where p and q are relatively prime. What is the largest amount of postage that cannot be produced using these stamps. Solution. Let G = {p, q } and let P be P3 . The largest amount not representable is pq p q . If pq p q were so representable, then

pq p q = (M 1)p + (N 1)q where M and N are POSITIVE integers. However, since pq = M p + N q and (p, q ) = 1 it follows that p|N (since p|N q ). Similarly q |M . But then M p + N q must be of the form Kpq + Lpq where K and L are both POSITIVE integers which contradicts pq = M p + N q = Kpq + Lpq . So we know that pq p q is not representable. To show that this is the largest such number, observe that any positive integer k can be written in the form () k = Ap + Bq

where A and B are (not necessarily positive) integers. It follows from (*) that k > 0 can be written in the form k = M p + N q where N is positive and q < M <= 0. Now, consider pq + k = pq + M p + N q = (q + M )p + N q. We see that (q + M ) and N are both positive. Thus, we have proved that any integer greater than pq can be written in the form M p + N q where M and N are positive. Finally then, if k > pq p q , we have k + p + q = M p + N q where M and N are positive so that k = (M 1)p + (N 1)q as desired. 4. The Balance Pan Problem. Given a nite set {w1 , w2 , w3 , . . . , wn }, and a two-pan balance, what is the largest number of weights which can be determined by the wi ? How should the values w1 , w2 , w3 , . . . , wn be selected to minimize the number of duplicated values? Solution. There are three things we can do with each weight: a) put it on the left pan, b) put it on the right pan, or c) leave it out. Thus there are 3n ways to distribute the weights. But one of these is the one with no weights on either pan, and half the rest are obtainable from the other half by switching the weights in the two pans. For each conguration of weights, (U, V ), where U represents the set of weights on the left pan and V those on the right, there corresponds the sum iV j U .

Zero corresponds to the conguration (, ), and the transformation iV j U iU j V represents a one-to-one correspondance between positive sums and negative sums. Hence the set R of results n 1 has cardinality at most 3 2 . This occurs when no two congurations give the same sum. Note that the set { ai wi |ai {0, 1, 1}} has 3n members if and only if { (ai + 1)wi |ai {0, 1, 1}} has 3n members. We have the following theorem the proof of which is omitted:Theorem n 1 The set R of weighable values is the set {1, 2, 3, . . . 3 2 } if and only of the set of weights is 1, 3, 9, . . . , 3n1 . Thus this problem is obtainable by choosing G as the powers of 3, and P as the process P4 with A = {1, 0, 1}. 5. McNuggets Problem. Chicken McNuggets come in packages of size 6, 9 and 20. What is the largest number of McNuggets which cannot be purchased? Solution. Since 6 and 9 have a gcd of 3, and 20 is congruent to 2 modulo 3, it makes sense to distinguish three sets, S0 , S1 , and S2 , dened as follows: S0 = {n|n = 6a + 9b for some non-negative integers a and b} S1 = {n|n = 6a + 9b + 20 for some non-negative integers a and b} and S2 = {n|n = 6a + 9b + 40 for some non-negative integers a and b}. Thus, S0 = {6, 9, 12, 15, 18, 21, . . .} S1 = {20, 26, 29, 32, 35, 38, 41, 44, . . .} and S2 = {40, 46, 49, 52, . . .}. Therefore, by inspection we see that 43 is the largest number not in S0 S1 S2 .

6. How many integers can be obtained as a sum of two or more of the numbers 1, 3, 5, 10, 20, 50, 82? (Alan Tuckers Applied Combinatorics, problem 40, page 179.) Solution. Each member of G = {1, 3, 5, 10, 20, 50, 82} is larger than the sum of the smaller members of G except 82. Therefore the only duplicated sums involve 82. The minimal duplicated sums are 82 + 1 = 50 + 20 + 10 + 3 and 82 + 3 = 50 + 20 + 10 + 5. The other duplicates is 88 and 86. Thus there are 27 7 1 4 = 116 1
7 1

dierent sums, since we dont want to count the empty sum, and the four duplicated values.

= 7 singletons, the

7. If pairs of distinct elements of the set S are added, the following ten numbers are obtained: 1967, 1972, 1973, 1974, 1975, 1980, 1983, 1984, 1989, 1991. What are the elements of S ? (USAMTS, 1995) Solution. Since 5 = 10 it makes sense to look for a ve element 2 set. (In fact there are six element sets which have exactly 10 distinct pairwise sums. Can you nd one?) Suppose the elements of the set are a < b < c < d < e. Then the ten pairwise sums are {a + b, a + c, b + c, a + d, b + d, a + e, b + e, c + d, c + e, d + e} but they are not necessarily in order from smallest to largest. We can say that the smallest, a + b = 1967, the largest d + e = 1991, and the sum of them all is a + b + c + d + e = 1 (1967 + 1972 + 1973 + 1974 + 1975 + 1980 + ... + 1991) = 4947, because 4 each of the numbers a, b, c, d, e appears in exactly four sums. It follows that c = 989. Since a + c is the second largest in the list, it follows that a = a + c c = 1972 989 = 983 and from this it follows that b = 1967 983 = 984. Reasoning similarly results in e = 1000 and d = 991.

8. Use each of the nine digits 1, 2, 3, 4, 5, 6, 7, 8, and 9 exactly twice to form distinct prime numbers whose sum is as small as possible.(USAMTS, 1991) Solution. From M&IQ, No. 3, 1992. Clearly 4, 6, and 8 cannot occur as the units digit. Similarly, 2 and 5 may occur as units digit at most once. Thus the sum must be at least (2(4 + 6 + 8) + (2 + 5))10 + (2 + 5) + 2(1 + 3 + 7 + 9) = 477. To see that 477 can be attained, we rst note that the only two primes in the 80s are 83 and 89, and that the only two in the 60s are 61 and 67. This leads to the solutions 2 + 5 + 23 + 41 + 47 + +59 + 61 + 67 + 83 + 89 = 477 and 2 + 5 + 29 + 41 + 47 + 53 + 61 + 67 + 83 + 89 = 477. Can you solve this problem when each digit must be used exactly once?. . . exactly thrice? 9. How many numbers can be obtained as the product of two or more of the numbers 3, 4, 4, 5, 5, 6, 7, 7, 7? (Alan Tuckers Applied Combinatorics, problem 34, page 179.) Solution. Take G as the multiset {3, 4, 4, 5, 5, 6, 7, 7, 7}, and P as the process P1 with the modication that we must use at least two members of G and we multiply instead of add. Note that each member n of R uniquely determines the subset Sn of G whose product it is. We claim that each product in R uniquely determines its factors among the multiset. Factor the product n of members of G into primes to get something of the form n = 2i 3j 5k 7l . The exponent i is odd if and only if the 6 appears in the product. The number of 5s and 7s in Sn is just i k and l respectively and the number of 4s is 2 . The number of 6s

i is i 2 2 , and the number of 3s is j minus the number of 6s. Thus the number of members of R is the number alternative ways to treat the various values. We can include the 3 or not, include the 6 or not, include 0, 1, or 2 of the 4s, 0,1, or 2 of the 5s, and 0,1,2, or 3 of the 7s. This number is

2 2 3 3 4 1 5 = 138. 10. Brackets can be inserted into the expression 1 2 3 4 in various ways. For example, (1 2) (3 4) equals 2/3 whereas 1 ((2 3) 4) equals the whole number 6. Similarly, brackets can be inserted into 1 2 3 4 5 6 7 8 9 10 11 to produce a large collection of answers, many of which are integers. What do you get if you divide the largest of these integers by the smallest of these integers? (London Times Brainteaser #1696). Solution. This problem is related to the choices G = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11} and P = P5 , with the requirement that only s appear in the expression and the members of G appear in numerical order. The numbers produced are precisely 1 . . . , 2abc . . . where each of the numbers 1, 2, 3, 4, . . . , 11 appears exactly once. Another way to write these is as 11! , (2abc . . .)2 where a, b, c, . . . belong to {3, 4, . . . , 11}. The largest integer value is 11! = 9979200. Since 11! = 11 7 5 5 3 3 3 3 2 2 2 2 2 2 2 2 = 22 11 7(2 5 8 9)2 , it follows that the smallest integer is 11! = 77. (2 5 8 9)2

Therefore the quotient in question is 9979200 77 = 129600. In fact 1 (((((((((2 3) 4) 5) 6) 7) 8) 9) 10) 11) = 3 4 5 6 7 8 9 10 11 = 9, 979, 200. 2 On the other hand, ((((1 2) 3) 4) 5) (((((6 7) 8) 9) 10) 11) = 7 8 9 10 11 = 77. 23456

11. How many of the rst 100 positive integers are expressible as a sum of three or fewer members of the set {30 , 31 , 32 , 33 , 34 } if we are allowed to use the same power more than once. For example, 5 can be represented, but 8 cannot. (1991 State Math Contest of North Carolina.) Solution. The number of powers of 3 used is just the sum of the ternary digits. It is useful therefore to consider the numbers from 1 to 26, 27 to 53, 54 to 80, and 81 to 100. Numbers in the range 1 to 26 have ternary representation of the form (a2 a1 a0 )3 . How many of these satisfy a2 + a1 + a0 3? There are 16 such numbers. Those in the range 27 to 53 all have the form (1a2 a1 a0 )3 . There are 10 for which a2 + a1 + a0 2. The number in the range 54 to 80 have the form (2a2 a1 a0 )3 . Only 4 of these satisfy a2 + a1 + a0 1. The numbers from 81 to 100 all have the form (1a3 a2 a1 a0 )3 . We want to know how many of that form are less than 100 and satisfy 1 + a3 + a2 + a1 + a0 3. There are 10 numbers in this range which satisfy the conditions. Hence there are 16 + 10 + 4 + 10 = 40 such numbers altogether. 12. How many integers can be expressed as a sum of two or more dierent members of the set {0, 1, 2, 4, 8, 16, 31}? (1994 UNC Charlotte Comprehensive Exam.)

Solutions. Take G as the set {1, 2, 4, 8, 16, 31}, and P as P1 . The 0 in the set means that we should count the individual elements among the sums. If the 31 was a 32, wed have unique (binary) representation. Hence the number of sums is just 26 minus 1(the empty sum) minus the duplicated values, of which there is just one. Hence there are 64 2 = 62 members of R. Each of the numbers 1, 2, 3, 4, 5, . . . , 62 is achievable, and 62 is certainly the largest member of R. 13. In a standard inx calculator, unparenthesized expressions are evaluated as follows: (a) Multiplications and divisions are done rst, starting at the left and moving to the right. (b) Additions and subtractions are done, again moving from left to right. . How many dierent values are For example, 1 2 + 3 4 is 3 2 3 possible if each is replaced by one of +, , , or in the expression 1 1 1 1 1 1 1 1? (1987 State Math Contest of North Carolina.) Solution. Inserting a pluses, b minuses, c times and d divs results in an expression with value 1 + a b where a + b 7. Thus 7 a b 7 implies that there are 15 dierent values. 14. The number 113 can be expressed as a sum of multiples of powers of 3. In fact, there exist integers a0 , a1 , a2 , a3 , a4 , such that 0 ai 2 and 113 = a4 (3)4 + a3 (3)3 + a2 (3)2 + a1 (3)1 + a0 (3)0 . Find the value of a0 + a1 + a2 + a3 + a4 . (1990 State Math Contest of North Carolina.) Use the standard repeated division algorithm to nd the base 3 representation of 113, being careful to obtain a remainder of 0, 1 or 2 to get 113 = 221223 .

15. John has 2 pennies, 3 nickels, 2 dimes, 3 quarters, and 8 dollars. For how many dierent amounts can John make an exact purchase? Solution. Well count achievable amounts less than $1, and multiply by 9, then add in the 9 values 9.00, 9.01, 9.02, 9.05, 9.06, 9.07, 9.10, 9.11, 9.12. They are {0, 1, 2, 5, 6, 7, 10, 11, 12, . . .}, exactly three of every ve con3 secutive values. So, counting 0, there are 5 (100) = 60 such values. Hence there are 9 60 1 = 539, since we dont count the value 0. Now adding in the nine uncounted values, we get 539 + 9 = 548. 16. Show that 1997 can be written in the form 12 22 3 2 k 2 for some positive integer k . Next show that every positive integer can be written in this way. (Paul Erd os) Hint: k 2 (k + 1)2 (k + 2)2 + (k + 3)2 = 4.

You might also like