标签:
Time Limit: 10000MS | Memory Limit: 64000K | |
Total Submissions: 3064 | Accepted: 1505 | |
Case Time Limit: 2000MS | Special Judge |
Description
Input
Output
Sample Input
1 2
Sample Output
3.0000
Source
#include <cstdio> #include <iostream> #include <sstream> #include <cmath> #include <cstring> #include <cstdlib> #include <string> #include <vector> #include <map> #include <set> #include <queue> #include <stack> #include <algorithm> using namespace std; #define ll long long #define _cle(m, a) memset(m, a, sizeof(m)) #define repu(i, a, b) for(int i = a; i < b; i++) #define MAXN 1005 double d[MAXN][MAXN]; int main() { int n, s; while(~scanf("%d%d", &n, &s)) { _cle(d, 0); for(int i = n; i >= 0; i--) for(int j = s; j >= 0; j--) { if(i == n && j == s) ; else { d[i][j] = ((d[i + 1][j + 1] + 1.0) * (double)((n - i) * (s - j)) + (d[i + 1][j] + 1.0) * (double)((n - i) * (j)) + (d[i][j + 1] + 1.0) * (double)((i) * (s - j)) + i * j) / (double)(n * s - i * j); } } printf("%.4lf\n", d[0][0]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/sunus/p/4442336.html