Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int r,n,k;
  5.  
  6. double NdivK(int round)
  7. {
  8. int g=n-r;
  9. int d=n-1;
  10. double ulamek=1;
  11. for(int i=0;i<round;i++)
  12. {
  13. ulamek*=g;
  14. ulamek/=d;
  15. g--;
  16. d--;
  17. }
  18. return ulamek;
  19. }
  20. int main()
  21. {
  22. cin>>k>>r;
  23. n=(1<<k);
  24. int round=1;
  25. double sum=0;
  26. int i=1;
  27. while(round<n-r)
  28. {
  29. sum+=NdivK(round);
  30. //cout<<round<<" ulamek "<<NdivK(round)<<'\n';
  31. i++;
  32. round=(1<<i)-1;
  33.  
  34. }
  35. int a=sum;
  36. cout.precision((int)log10(a)+6);
  37. cout<<sum;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement