Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long double comb(long double n, long double k)
- {
- long double ans = 1;
- long double lim = n - k;
- long double j = 1;
- long double q = 1;
- for(long double i = k + 1; i <= n; i++)
- {
- ans *= i;
- if(j <= lim)
- {
- ans /= j;
- j++;
- }
- while(ans >= 1 && q <= n)
- {
- ans *= 0.5;
- q++;
- }
- }
- while(j <= lim)
- {
- ans /= j;
- j++;
- }
- while(q <= n)
- {
- ans *= 0.5;
- q++;
- }
- return ans;
- }
- int main()
- {
- int x, y;
- cin >> x >> y;
- x--;
- y--;
- long double a = comb(x + y, y);
- cout << a << "\n";
- return 0;
- }
- /**
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement