HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Kovrov IT > problem:


2007.D. 50271 - Factorial

Guest
• Discussion of problem (1)

Volume problems

• 2007.A. 50671 - Phalanx
• 2007.B. 50270 - Bitsorting
• 2007.C. 50640 - Cubes
• 2007.D. 50271 - Factorial
• 2007.E. 50663 - Lights
• 2007.F. 50690 - Parliament
• 2007.G. 50272 - Strange Numbers
• 2007.H. 50273 - Two Captains
• 2007.I. 50274 - Boundary Troops
• 2007.J. 50275 - Wedding
• 2007.K. 50276 - Nice Floor
• 2008.A. 50672 - Math and Soldiers

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