Greece National Olympiad Problem 3

How many 5 digit positive integers are there such that each of its digits, except for the last one, is greater than or equal to the next digit?

This problem is part of this set .


The answer is 2001.

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.

4 solutions

Widyanto Nugroho
Mar 12, 2018

Lets we assume that every digit from 0 to 9 is a, b, c, d, ... i. Then, we can form an equality a+b+c+d+e+f+g+h+i+j=5 (five is the total of its digits). This is a classic problem. We use the permutation there are 5 objects divide into 10 section that separated by 9 another objects. So it becomes 14!/9!5!. 14C5 is 2002. But there is one solution that isn't accepted when all of its digits are zero. So the answer is 2002-1=2001

Soumava Pal
Mar 20, 2016
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
>>> def f(n):
        n=str(n)
        if n[0]>=n[1] and n[1]>=n[2] and n[2]>=n[3] and n[3]>=n[4]:
            return 1
        return 0
>>> c=0
>>> for i in range(10000,100000):
        c+=f(i)

>>> c
2001

But, when you run this code, you get 2001:

   Dim counter As Integer = 0

    For n = 10000 To 99999

        Dim a As String = n.ToString

        Dim a_char() = a.ToCharArray

        If ((a(0) >= a(1)) And (a(1) >= a(2)) And (a(2) >= a(3)) And (a(3) >= a(4))) Then

            counter = counter + 1

        End If

    Next

    Console.WriteLine(counter)

    Console.ReadLine()

I got 2002 :/. Is n = 10000 to 99999 inclusive?

Brian Wang - 5 years, 2 months ago

Log in to reply

Both 10000 and 99999 are included.

Kamala Ramakrishnan - 5 years, 2 months ago
Vishnu C
Mar 22, 2015

I f y o u f o l l o w t h e p a t t e r n o f t h e w a y t h e s e n u m b e r s a r e f o r m e d , y o u c a n s e e s u c h a p a t t e r n f o r w h e n t h e d i g i t i i s a t t h e 10 , 00 0 s p l a c e : I f k 1 ( i ) r e p r e s e n t s t h e n u m b e r o f n u m b e r s l i k e i i i i _ , i . e , t h e n u m b e r o f n u m b e r s w i t h i e v e r y w h e r e b u t t h e u n i t s p l a c e , t h e n k 1 ( i ) = i + 1. F o l l o w i n g t h e w e i r d r e c u r s i v e p a t t e r n , k 10 ( i ) = 0 i k 1 ( r ) = 0 i ( r + 1 ) = ( i + 1 ) ( i + 2 ) 2 . H e r e , k 10 ( i ) r e p r e s e n t s t h e n u m b e r o f n u m b e r s l i k e i i i _ _ . S i m i l a r l y , k 100 ( i ) = 0 i ( r + 1 ) ( r + 2 ) 2 = 0 i k 10 ( r ) = ( i + 1 ) ( i + 2 ) ( i + 3 ) 6 . F o r t h e l a s t o n e , k 1000 ( i ) , r e p r e s e n t i n g i _ _ _ _ , w e g e t t h e n u m b e r o f n u m b e r s s t a r t i n g w i t h d i g i t i a n d s u b j e c t t o g i v e n c o n d i t i o n s . k 1000 ( i ) = 0 i k 100 ( r ) = ( i + 1 ) ( i + 2 ) ( i + 3 ) ( i + 4 ) 24 . N o w f o r t h e t o t a l n u m b e r o f s u c h n u m b e r s , N = 1 9 k 1000 ( r ) = 2001. W h e n I e n t e r e d 2001 , i t n a t u r a l l y s a i d w r o n g . I a s s u m e d t h a t t h e q u e s t i o n w a s s u p p o s e d t o i n c l u d e 00000. I e n t e r e d 2002 a n d i t s a i d t h a t i t w a s c o r r e c t . I r e c h e c k e d i t w i t h a c o m p u t e r p r o g r a m a n d i t s a i d t h e s a m e t h i n g . I t h i n k t h a t t h e q u e s t i o n w a s m e a n t t o r e a d , a l l n o n n e g a t i v e i n t e g e r s . I f 2002 i s t h e r i g h t a n s w e r a n d a n y o n e h a s o b t a i n e d i t w i t h o u t i n c l u d i n g 00000 , w h i c h i s n o t a p o s i t i v e i n t e g e r , p l e a s e l e t m e k n o w . If\quad you\quad follow\quad the\quad pattern\quad of\quad the\quad way\quad these\quad numbers\quad are\quad \\ formed,\quad you\quad can\quad see\quad such\quad a\quad pattern\quad for\quad when\quad the\quad digit\quad \\ { i }\quad is\quad at\quad the\quad 10,000's\quad place:\\ If\quad { k }_{ 1 }(i)\quad represents\quad the\quad number\quad of\quad numbers\quad like\\ \overline { i\quad i\quad i\quad i\quad \_ } ,\quad i.e,\quad the\quad number\quad of\quad numbers\quad with\quad i\quad everywhere\\ but\quad the\quad units\quad place,\quad then\quad \quad { k }_{ 1 }(i)\quad =i+1.\\ Following\quad the\quad weird\quad recursive\quad pattern,\quad { k }_{ 10 }(i)=\sum _{ 0 }^{ i }{ { k }_{ 1 }(r) } \\ =\sum _{ 0 }^{ i }{ (r+1) } =\frac { (i+1)(i+2) }{ 2 } .\\ Here,\quad { k }_{ 10 }(i)\quad represents\quad the\quad number\quad of\quad numbers\quad like\\ \overline { i\quad i\quad i\quad \_ \quad \_ } .\quad Similarly,\quad { k }_{ 100 }(i)=\sum _{ 0 }^{ i }{ \frac { (r+1)(r+2) }{ 2 } } \\ =\sum _{ 0 }^{ i }{ { k }_{ 10 }(r) } =\frac { (i+1)(i+2)(i+3) }{ 6 } .\\ For\quad the\quad last\quad one,\quad { k }_{ 1000 }(i),\quad representing\quad \overline { i\quad \_ \quad \_ \quad \_ \quad \_ } ,\quad we\quad \\ get\quad the\quad number\quad of\quad numbers\quad starting\quad with\quad digit\quad i\quad and\quad \\ subject\quad to\quad given\quad conditions.\\ \\ { k }_{ 1000 }(i)=\sum _{ 0 }^{ i }{ { k }_{ 100 }(r) } =\frac { (i+1)(i+2)(i+3)(i+4) }{ 24 } .\\ Now\quad for\quad the\quad total\quad number\quad of\quad such\quad numbers,\quad \\ N\quad =\quad \sum _{ 1 }^{ 9 }{ { k }_{ 1000 }(r) } =2001.\\ When\quad I\quad entered\quad 2001,\quad it\quad naturally\quad said\quad wrong.\quad I\quad assumed\\ that\quad the\quad question\quad was\quad supposed\quad to\quad include\quad 00000.\quad I\quad entered\quad \\ 2002\quad and\quad it\quad said\quad that\quad it\quad was\quad correct.\\ \\ I\quad rechecked\quad it\quad with\quad a\quad computer\quad program\quad and\quad it\quad said\quad the\quad \\ same\quad thing.\quad I\quad think\quad that\quad the\quad question\quad was\quad meant\quad to\quad read,\\ 'all\quad non-negative\quad integers'.\\ If\quad 2002\quad is\quad the\quad right\quad answer\quad and\quad anyone\quad has\quad obtained\quad it\quad \\ without\quad including\quad 00000,\quad which\quad is\quad not\quad a\quad positive\quad integer,\quad \\ please\quad let\quad me\quad know.

Solve it my way

Let it be a b c d e abcde then 13 a + 4 > b + 3 > c + 2 > d + 1 > e 0 13\ge a+4>b+3>c+2>d+1>e\ge0 so it is equal to the ways to choose 5 5 different numbers out of 14 14 Hence answer is ( 14 5 ) = 2002 \dbinom{14}{5} = \boxed{2002}

Parth Lohomi - 6 years, 2 months ago

Log in to reply

Thanks! Your method is much shorter than mine! Wish I had thought of that.

vishnu c - 6 years, 2 months ago

Log in to reply

Wait, I still have one doubt: you said that it's the same as choosing 5 nos out of 14 in the set {0,1,...,12,13}. So this choice: {0,1,2,3,4} would also be in it, right? That means a=b=c=d=e=0. So the number effectively formed = 00000 = 0 is not positive. Correct me if I'm wrong, but I still think that the question should be changed to non negative integers.

vishnu c - 6 years, 2 months ago

Thanks. In future, if you spot any errors with a problem, you can “report” it by selecting "report problem" in the “dot dot dot” menu in the lower right corner. This will notify the problem creator who can fix the issues.

Calvin Lin Staff - 6 years, 2 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...