当前位置:网站首页>On the number of solutions of indefinite equations
On the number of solutions of indefinite equations
2022-07-24 13:50:00 【lAWTYl】
The number of solutions of the indefinite equation
Lv0
First of all, let's look at such a problem , seek ∑ i = 1 n x i = b \sum\limits_{i = 1}^n x_i = b i=1∑nxi=b The number of nonnegative integer solutions of .
This problem is very simple , Let's transform him a little , This problem is equivalent to having n n n A child points b b b A candy , Each child gets at least 0 0 0 A candy ( What a tragedy ), Find the number of schemes to divide the candy .
Then we will transform the problem , Now there is b b b Candy in a row , Put it in it n − 1 n - 1 n−1 A board ( There can be multiple boards in the same grid ), In this way, these candies can be divided into n n n part , Find the number of plans for square planks .
It's obvious , The answer is a total of n + b − 1 n + b - 1 n+b−1 Grid options , Choose among them n − 1 n - 1 n−1 The number of schemes in a grid , That is to say C n + b − 1 n − 1 C_{n + b - 1}^{n - 1} Cn+b−1n−1.
Lv1
There is another problem , seek ∑ i = 1 n x i = b \sum\limits_{i = 1}^nx_i = b i=1∑nxi=b And x i ≥ l i x_i \geq l_i xi≥li The number of nonnegative integer solutions of . Obviously, we don't want the following constraints , So we consider this :
∑ i = 1 n x i = b − ∑ i = 1 n l i \sum_{i = 1}^nx_i = b - \sum_{i = 1}^nl_i i=1∑nxi=b−i=1∑nli
In this way, we will transform the problem into the same form as the first problem ( It's equivalent to we lose x i < l i x_i < l_i xi<li The contribution of ), The answer is :
a n s = ( n + b − ∑ i = 1 n l i − 1 n − 1 ) ans = \begin{pmatrix} n + b - \sum\limits_{i = 1}^n l_i - 1 \\ n - 1 \end{pmatrix} ans=⎝⎛n+b−i=1∑nli−1n−1⎠⎞
Lv2
Last question , seek ∑ i = 1 n x i = b \sum\limits_{i = 1}^nx_i = b i=1∑nxi=b And x i ≤ r i x_i \leq r_i xi≤ri The number of nonnegative integer solutions of . This problem is not as good as the previous one . So we consider letting go x i ≥ r i + 1 x_i \geq r_i + 1 xi≥ri+1 The contribution of .
We ordered the assembly S S S Express ∑ i = 1 n ( x i ≥ r i + 1 ) \sum\limits_{i = 1}^n(x_i \geq r_i + 1) i=1∑n(xi≥ri+1) Binary set of . This is equivalent to asking S = { 0 , 0 , ⋯ , 0 } S = \{ 0, 0, \cdots, 0 \} S={ 0,0,⋯,0} The answer when . We make f ( S ) f(S) f(S) Indicates that the binary set is S S S The answer is . Then there are :
f ( S = { 0 , 0 , ⋯ , 0 } ) = t o t − ∑ S ⊂ U ( − 1 ) ∣ S ∣ + 1 f ( S ) f(S = \{0, 0, \cdots, 0\}) = tot - \sum_{S \subset U}(-1)^{|S| + 1}f(S) f(S={ 0,0,⋯,0})=tot−S⊂U∑(−1)∣S∣+1f(S)
among t o t tot tot Represents the total number , That is the answer to the first question . U = { 0 , 0 , ⋯ , 0 } U = \{ 0, 0, \cdots, 0 \} U={ 0,0,⋯,0} ( n n n individual 0 0 0). The above formula is the inclusion exclusion principle .
And then one of them ( Equivalent to the second problem ):
f ( S ) = ( n + b − 1 − ∑ i ∈ S ( r i + 1 ) n − 1 ) f(S) = \begin{pmatrix} n + b - 1 - \sum\limits_{i \in S} (r_i + 1) \\ n - 1 \end{pmatrix} f(S)=(n+b−1−i∈S∑(ri+1)n−1)
therefore :
a n s = ( n + b − 1 n − 1 ) − ∑ S ⊂ U ( − 1 ) ∣ S ∣ + 1 f ( S ) = ( n + b − 1 n − 1 ) + ∑ S ⊂ U ( − 1 ) ∣ S ∣ ( n + b − 1 − ∑ i ∈ S ( r i + 1 ) n − 1 ) = ∑ S ⊆ U ( − 1 ) ∣ S ∣ f ( S ) \begin{aligned} ans & = \begin{pmatrix} n + b - 1 \\ n - 1 \end{pmatrix} - \sum_{S \subset U}(-1)^{|S| + 1} f(S) \\ & = \begin{pmatrix} n + b - 1 \\ n - 1 \end{pmatrix} + \sum_{S \subset U} (-1)^{|S|} \begin{pmatrix} n + b - 1 - \sum\limits_{i \in S}(r_i + 1) \\ n - 1 \end{pmatrix} \\ & = \sum_{S \subseteq U} (-1)^{|S|}f(S) \end{aligned} ans=(n+b−1n−1)−S⊂U∑(−1)∣S∣+1f(S)=(n+b−1n−1)+S⊂U∑(−1)∣S∣(n+b−1−i∈S∑(ri+1)n−1)=S⊆U∑(−1)∣S∣f(S)
边栏推荐
猜你喜欢

rhcsa第六次笔记

Network security - filtering bypass injection

Apache2 ha experiment with raspberry pie

Network security - function bypass injection

Why are there "two abstract methods" in the functional interface comparator?

网络安全——报错注入

Network security - file upload blacklist bypass

网络安全——中间人攻击渗透测试

HCIP第十三天

Network security - file upload whitelist bypass
随机推荐
R语言epiDisplay包的kap函数计算Kappa统计量的值(总一致性、期望一致性)、对多个评分对象的结果进行一致性分析、评分的类别为多个类别、如果评分中包含缺失值则标准误及其相关统计量则无法计算
Rhcsa sixth note
CSP2021 T1 廊桥分配
Flink高级特性和新特性(八)v2
Exploration of sustainable learning ability to support the application of ecological evolution of Pengcheng series open source large models
position: -webkit-sticky; /* for Safari */ position: sticky;
申请了SSL数字证书如何进行域名验证?
Network security - file upload competitive conditions bypass
网络安全——文件上传内容检查绕过
SQL Server 启停作业脚本
Flink advanced features and new features (VIII) V2
The R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graphs, uses the by parameter to specify the groupi
数据类型二进制字符串类型
网络安全——文件上传白名单绕过
Paper notes: swing UNET: UNET like pure transformer for medicalimage segmentation
Network security - penetration using evil maid physical access security vulnerabilities
Unity UGUI中scroll bar在游戏中启动界面时没有从最上面显示
Network security - Web penetration testing
网络安全——函数绕过注入
OWASP ZAP安全测试工具使用教程(高级)