NOI '01 P5 - Equation Solutions

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type
National Olympiad in Informatics, China, 2001

Given an n-th order equation:

k1x1p1+k2x2p2++knxnpn=0

where: x1,x2,,xn are the unknowns, k1,k2,,kn are the coefficients, and p1,p2,,pn are the exponents. Additionally, each value in the equation is an integer.

Assume that the unknowns will satisfy 1xiM for i=1n. Find the number of integer solutions.

Input Specification

The first line of input contains the integer n.
The second line of input contains the integer M.
Lines 3 to n+2 will each contain two space-separated integers, the values of ki and pi respectively. Line 3 corresponds to when i=1, and line n+2 corresponds to when i=n.

Output Specification

Output one integer - the number of integer solutions that solve the equation.

Sample Input

Copy
3
150
1 2
-1 2
1 2

Sample Output

Copy
178

Constraints

  • 1n6
  • 1M150
  • |k1Mp1|+|k2Mp2|++|knMpn|<231
  • The number of solutions will be less than 231.
  • The exponents Pi (i=1,2,,n) in this problem will each be a positive integer.

Problem translated to English by Alex.


Comments

There are no comments at the moment.