zoj 2996 (1+x)^n

来源:互联网 发布:郑州大学软件学院算211 编辑:程序博客网 时间:2024/06/08 14:21

点击打开链接

(1+x)^n

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Please calculate the coefficient modulo 2 of x^i in (1+x)^n.

Input

For each case, there are two integers n, i (0<=i<=n<=2^31-1)

Output

For each case, print the coefficient modulo 2 of x^i in (1+x)^n on a single line.

Sample Input

3 14 2

Sample Output

10
我自己想不出来,只能是没听过这个知识点,判断C(n,i)的奇偶性,如果它是奇数就满足(n&i)==i
#include<iostream>  using namespace std;  int main()  {      int n,i;      while(cin>>n>>i)      {          if((n&i)==i)              cout<<1<<endl;          else              cout<<0<<endl;      }      return 0;  }  


原创粉丝点击