eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Teaching Hazard

Teaching Hazard

Teaching students is fun but it can often be embarrassing, which I experienced a few days ago. I was taking CSE3021 (Mathematical Analysis for Computer Science) class in my university and in the very first class I was teaching some very basic things. To be specific I was trying to teach students how to find trailing zeroes of \textbf{n!} (factorial \textbf{n}) in base \textbf{b}. And of course many of you know that multiplicity of a prime factor \textbf{p} in \textbf{n!} can be found using the formula \includegraphics{https://static.e-olymp.com/content/75/7543ef0a12fd73daa02a339e312acd1cf1c739ce.jpg} + ... to inf. This formula can also be used cleverly to find number of trailing zeroes in \textbf{n!}. After teaching this formula I showed them how to find number of trailing zeroes in \textbf{200!} in decimal number system and with an evil smile asked them to find out number of trailing zeroes in \textbf{100!} in hexadecimal (\textbf{16}-based) number system. I knew that the correct answer is \textbf{24} and to my utter surprise I got a correct reply from a student within minutes and so I congratulated him. But a minute later when I checked his script I found that he actually calculated number of trailing zeroes in \textbf{100!} in decimal (not Hexadecimal) number system and coincidentally that both answers (Trailing zeroes in hexadecimal and decimal number system) were \textbf{24}. So I was a bit embarrassed and now you have to help me find out why those two answers were same? Given a number \textbf{n}, you will have to find how many pair of bases \textbf{(b_1, b_2)} are there for which \textbf{n!} (Factorial \textbf{n}) has exactly \textbf{p} trailing zeroes in both base \textbf{b_1} and base \textbf{b_2}. Here \textbf{p} is a positive integer not less than \textbf{x}. \InputFile Input file contains \textbf{1000} lines of inputs. Each line contains two integers \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{100000}) and \textbf{x} (\textbf{2} ≤ \textbf{x} ≤ \textbf{2500}). Input is terminated by a line containing two zeroes. \OutputFile For each line of input produce one line of output. This line contains an integer which denotes number of base pairs \textbf{(b_1, b_2)} so that \textbf{n!} has exactly \textbf{p} trailing zeroes in both bases where \textbf{p} is not less than \textbf{x}. You can assume that inputs will be such that none of the output numbers will exceed \textbf{5·10^18}.
Лимит времени 20 секунд
Лимит использования памяти 128 MiB
Входные данные #1
6 2
9 3
0 0
Выходные данные #1
6
2
Автор Dr. Shahriar Manzoor
Источник ACM-ICPC Asia Phuket Regional Programming Contest 2013, 22 November 2013