eolymp
bolt
Try our new interface for solving problems
Problems

"Same quantity, sum and product"

"Same quantity, sum and product"

Your task is to write a program, which will count how many different multisets has \textbf{N} elements with sum \textbf{S} and product \textbf{P} (\textbf{1} ≤ \textbf{N} ≤ \textbf{2^\{5 \}= 32}, \textbf{1} ≤ \textbf{S} ≤ \textbf{2^\{15 \}= 32768} and \textbf{1} ≤ \textbf{P} ≤ \textbf{2^\{36 \}= 68719476736}). Two multisets are considered different when they differ by elements or by quantities of some elements. If two sequences differ by elements’ order only, they are the same multiset. \InputFile Input contains three space-separated integers \textbf{N}, \textbf{S} and \textbf{P} in the same line. \textbf{1} ≤ \textbf{N} ≤ \textbf{2^5=32}, \textbf{1} ≤ \textbf{S} ≤ \textbf{2^15=32768} and \textbf{1} ≤ \textbf{P} ≤ \textbf{2^36=68719476736}. \OutputFile Output exactly one integer number --- the quantity of different multisets. \Note The \textbf{12} multisets for \textbf{1^st} test case are: \textbf{1 2 3 4 5 6 7 8 9} \textbf{1 2 3 4 6 6 6 7 10} \textbf{1 2 4 4 4 5 7 9 9} \textbf{1 3 3 3 4 6 7 8 10} \textbf{1 3 3 4 4 4 7 9 10} \textbf{1 3 3 4 4 5 6 7 12} \textbf{2 2 2 3 4 6 7 9 10} \textbf{2 2 2 3 5 6 6 7 12} \textbf{2 2 3 3 3 5 7 8 12} \textbf{2 2 3 3 4 5 6 6 14} \textbf{2 3 3 3 3 4 5 8 14} \textbf{2 3 3 3 4 4 4 7 15}
Time limit 4 seconds
Memory limit 64 MiB
Input example #1
9 45 362880
Output example #1
12
Author Ilya Porublev
Source ACM-ICPC Ukraine 2013, 2nd Stage Ukraine, September 10-12, 2013