Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int r,n,k;
- double NdivK(int round)
- {
- int g=n-r;
- int d=n-1;
- double ulamek=1;
- for(int i=0;i<round;i++)
- {
- ulamek*=g;
- ulamek/=d;
- g--;
- d--;
- }
- return ulamek;
- }
- int main()
- {
- cin>>k>>r;
- n=(1<<k);
- int round=1;
- double sum=0;
- int i=1;
- while(round<n-r)
- {
- sum+=NdivK(round);
- //cout<<round<<" ulamek "<<NdivK(round)<<'\n';
- i++;
- round=(1<<i)-1;
- }
- int a=sum;
- cout.precision((int)log10(a)+6);
- cout<<sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement