Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int C(int n, int k) {
- double ans = 1;
- for (int i=1; i<=k; i++)
- ans = ans * (n-k+i) / i;
- return (int) (ans + 0.01);
- }
- double fast_pow(double a, int b) {
- if (b == 0) return 1;
- else {
- double t = fast_pow(a, b/2);
- if (b%2) return t*t*a;
- else return t*t;
- }
- }
- int main()
- {
- int m, n, k;
- cin >> m >> n >> k;
- double ans = 0.0;
- for (int i=1; i<=k; i++)
- ans += C(k,i) * fast_pow(1./m/n, i) * fast_pow(1. - 1./m/n, k-i);
- ans *= m*n;
- cout << fixed << setprecision(10) << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement