Advertisement
Tooster

newton's binomial

Mar 11th, 2015
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int A[2005][2005];
  4. void Newton(int n, int k)
  5. {
  6. if(n==0 || n==k)
  7. {
  8. cout<<1;
  9. return;
  10. }
  11. if(k==1 || k==n-1)
  12. {
  13. cout<<n;
  14. return;
  15. }
  16. A[0][0]=1;
  17. for(int i=1; i<=n+1; i++)
  18. {
  19. A[i][0]=1;
  20. for(int j=1; j<i; j++)
  21. {
  22. A[i][j]=A[i-1][j]+A[i-1][j-1]%10000;
  23. }
  24. }
  25. cout<<A[n+1][k]%10000;
  26. }
  27.  
  28.  
  29. int main()
  30. {
  31. int n,k;
  32. cin>>n>>k;
  33. Newton(n,k);
  34.  
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement