eolymp
bolt
Try our new interface for solving problems
Problems

Product sum

Product sum

There is a set of variables \textbf{x_1}, \textbf{x_2}, ..., \textbf{x_N}. Each variable \textbf{x_i} can be assigned the value \textbf{-1}, \textbf{0}, \textbf{+1} only. For a given integer p you are to calculate the number of ways variables \textbf{x_i} can be assigned values so that the sum of all possible products \textbf{x_i·x_j} is equal to \textbf{S}, where \textbf{i} < \textbf{j} and \textbf{i}, \textbf{j} = \textbf{1}, \textbf{2}, ..., \textbf{N}. Two ways are considered different if they contain a different number of \textbf{x_i} = \textbf{0}. \InputFile The input file contains two numbers: \textbf{N} and \textbf{S}, separated by space. \textbf{2} ≤ \textbf{N} ≤ \textbf{10000}, \textbf{-10000} < \textbf{S} < \textbf{10000}. \OutputFile The output file should contains only one integer -- the number of ways to represent \textbf{S} as a sum of products.
Time limit 1 second
Memory limit 64 MiB
Input example #1
5 0
Output example #1
3