#P5691. [NOI2001] 方程的解数

    ID: 5934 远端评测题 6000ms 500MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>数学2001NOI折半搜索 meet in the middle

[NOI2001] 方程的解数

Problem Description

Given an nn-variable higher-degree equation:

∑i=1nkixipi=0\sum\limits_{i=1}^n k_ix_i^{p_i} = 0

where x1,x2,…,xnx_1, x_2, \dots, x_n are the unknowns, k1,k2,…,knk_1, k_2, \dots, k_n are the coefficients, and p1,p2,…,pnp_1, p_2, \dots, p_n are the exponents. All numbers in the equation are integers.

Assume the unknowns satisfy xi∈[1,m] (i∈[1,n])x_i \in [1,m] \space ( i \in [1,n]). Find the number of integer solutions to this equation.

Input Format

The first line contains a positive integer nn, the number of unknowns.
The second line contains a positive integer mm.
The next nn lines each contain two integers ki,pik_i, p_i.

Output Format

Output one line with one integer, the number of solutions of the equation.

3
150
1 2
-1 2
1 2
178

Hint

【Constraints】

For 100%100\% of the testdata, 1≤n≤61\le n \le 6, 1≤m≤1501\le m \le 150, and

∑i=1n∣kimpi∣<231\sum\limits_{i=1}^n |k_im^{p_i}| < 2^{31}

The answer does not exceed 231−12^{31}-1, and pi∈N∗∩[0,231)p_i \in \mathbb N^*\cap[0,2^{31}).

Translated by ChatGPT 5