Advertisement
allia

сочетания доделать

Sep 14th, 2020
1,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. long long fact (int a)
  6. {
  7.   long long l=1;
  8.   if (a==0 || a==1)
  9.   l=1;
  10.   else  for (int i=2; i<a+1; i++)
  11.   l*=i;
  12.   return l;
  13. }
  14. int main()
  15. {
  16.   long long res=0;
  17.   int a=0, b=0;
  18.   cin >> a >> b;
  19.   if (a-b>=0)
  20.   {
  21.     res = fact(a)/(fact(b)*fact(a-b));
  22.     cout << res;
  23.   }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement