Skip to content

Instantly share code, notes, and snippets.

@ichirin2501
Created September 4, 2011 00:37
Show Gist options
  • Save ichirin2501/1192024 to your computer and use it in GitHub Desktop.
Save ichirin2501/1192024 to your computer and use it in GitHub Desktop.
srm460::div2::medium
#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