HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


50271 - Factorial

Guest
• Discussion of problem (1)

Section problems

• 51111 - Even Numbers
• 51115 - Pascal Triangle
• 51043 - Genome Sequencing
• 51116 - The Star Triangle
• 51042 - The most frequent k-mer
• 50271 - Factorial
• 50382 - Parkside's Other Triangle
• 51171 Question 3
• 51093 - rgb2gray
• 51165 Question 1
• 51175 Question 2
• 51092 - Even and Odd
• 51095 - Normal and Trace
• 50423 - Numbers square

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Автор: Павел Кузнецов, ПГУ. Difficulty Beta

For any positive integer N its factorial is defined in the following way:
N! = 1 · 2 · ... · N
Your task is to find K successive digits in a row in number N!, beginning from the first nonzero digit. See the examples for details.

Input
The first line of the input contains integers N and K (1 ≤ N ≤ 50000; 1 ≤ K ≤ 10).
Output
The output represents the answer to the question. The answer should have no spaces or other symbols except digits.

Input 1 Output 1
10 3
288
Comment: 10! = 3628800. The first nonzero digit is 8.
The three successive digits beginning with 8 are 288.
Input 2 Output 2
13 4
0208
Comment: 13! = 6227020800. The first nonzero digit is 8. The four
successive digits beginning with 8 are 0208. The leading 0 is obligatory!
Input 3 Output 3
5 10
12
Comment: 5! = 120. The first nonzero digit is 2. There are only two
successive digits beginning with 2, which is less than 10, so it is
necessary to write all of them without the leading zeros!

Для отправки решений необходимо выполнить вход.

www.contester.ru