Created
September 4, 2011 00:37
-
-
Save ichirin2501/1192024 to your computer and use it in GitHub Desktop.
srm460::div2::medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
#include <cstdio> | |
using namespace std; | |
class TheFansAndMeetingsDivTwo{ | |
public: | |
double find(vector <int> minJ, vector <int> maxJ, vector <int> minB, vector <int> maxB){ | |
double ret = 0.0; | |
int n = minJ.size(); | |
for(int i=0; i<n; i++){ | |
for(int j=0; j<n; j++){ | |
int sa = min(maxJ[i], maxB[j]) - max(minJ[i], minB[j]) + 1; | |
if( sa<=0 ) continue; | |
ret += (double)sa * (1.0/(double)(maxJ[i]-minJ[i]+1) * 1.0/(double)(maxB[j]-minB[j]+1)); | |
} | |
} | |
return ret/n/n; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment