Hello! Tell me how to create an algorithm for the task or a flowchart?

The task:

In the city of N there is a large warehouse on which there are 50,000 different shelves. For the convenience of the workers, the warehouse management decided to order a plate from 00001 to 50,000 for each shelf at the local printing house, but when the plates were printed, it turned out that the printing press did not print the number 2 due to a malfunction, so all the plates with one or more numbers in them Two (for example, 00002 or 20202) - must be reprinted. Write a program that calculates how many such erroneous plates were in the defective batch.

  • five
    @turtles all of your study tasks are called study tasks so that you can solve them or at least try. - yozh
  • @turtles, I remember you were looking for a teacher in Java. I recommend taking a look at [blackbeltfactory.com] [1]. This site offers training courses under the guidance of a mentor. Each course ends with an exam. [1]: blackbeltfactory.com - Nofate โ™ฆ
  • Thanks for the useful "Nofate" link - turtles
  • And also: here it is customary not to take the nickname in quotes, but to put a dog in front of it (@). So the parser can select a nickname and insert a link to the profile. - Nofate โ™ฆ
  • @karbachinsky. the answer can not be 28. But how to take into account the whole series of numbers 2ั…, 2ั…ั…, 2ั…ั…ั…, 2ั…ั…ั…ั…? - Ilya

2 answers 2

The algorithm for eliminating unnecessary numbers

You, in response to your post, have explained a similar task. This is even simpler - there is only one number here and itโ€™s necessary to count not those numbers that remain, but those that have dropped out. How many spamming tasks can be used on all forums?

http://www.javatalks.ru/ftopic26300/

http://www.sql.ru/forum/actualthread.aspx?tid=883775

  • Why so rude? anyway the administration will clean - jmu

In order to understand the pattern. Consider more simple examples.

In a simpler example: Let the labels be only 50 ... Options with two: 02 20 22

Let Plates only 500, variants with two: 002 020 022 202 220 222

The general formula: For N positions, we get the formula: 2 ^ N - (N-1).

Thus, for 50,000 N = 5 => Answer: 28 It seems to be so.

The problem would be more complicated if, for example, the numbers 7 were not printed :)

  • one
    Let there be only 50 tablets. Options with two: 02, 12, 22, 32, 42,20, 21, 23, ...29 Total 14. - vp_arth