这题有什么规律 Description Could you tell me the coefficient of x^k in (1+x)^n is odd or even?Input The first line of the input contains a integer T,indicate the number of test cases.For each case,there are two integers n,k (0 楼下能再讲
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/14 08:56:06
![这题有什么规律 Description Could you tell me the coefficient of x^k in (1+x)^n is odd or even?Input The first line of the input contains a integer T,indicate the number of test cases.For each case,there are two integers n,k (0 楼下能再讲](/uploads/image/z/8789086-46-6.jpg?t=%E8%BF%99%E9%A2%98%E6%9C%89%E4%BB%80%E4%B9%88%E8%A7%84%E5%BE%8B+Description+Could+you+tell+me+the+coefficient+of+x%5Ek+in+%281%2Bx%29%5En+is+odd+or+even%3FInput+The+first+line+of+the+input+contains+a+integer+T%2Cindicate+the+number+of+test+cases.For+each+case%2Cthere+are+two+integers+n%2Ck+%280+%E6%A5%BC%E4%B8%8B%E8%83%BD%E5%86%8D%E8%AE%B2)
这题有什么规律 Description Could you tell me the coefficient of x^k in (1+x)^n is odd or even?Input The first line of the input contains a integer T,indicate the number of test cases.For each case,there are two integers n,k (0 楼下能再讲
这题有什么规律
Description
Could you tell me the coefficient of x^k in (1+x)^n is odd or even?
Input
The first line of the input contains a integer T,indicate the number of test cases.
For each case,there are two integers n,k (0
楼下能再讲讲吗?
这题有什么规律 Description Could you tell me the coefficient of x^k in (1+x)^n is odd or even?Input The first line of the input contains a integer T,indicate the number of test cases.For each case,there are two integers n,k (0 楼下能再讲
这个是牛顿二项式定理的内容.
楼上说的不错.
其实你可以直接转化为排列组合就行了:
3 1,表示3个人里选1个人,判断选人的方法数是奇数还是偶数.
4 2,表示4个人里选2个人,判断选人的方法数是奇数还是偶数.
C(3,1)=3,奇数.C(4,2)=6,偶数.
其实就是让你求C(n,k)%2是==1,还是==0?
由于k和n很大,你就要用下面这种公式:
(A/B)%K=(A%(B*K))/B;
(A*B)%K=((A%K)*(B%K))%K;
牛顿二项式定理可以递归实现,判断奇偶性直接除2取余