func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int l[10], r[10];   double Prob(int id, int a, int b) {     int ini = max(a, l[id]);     int fim = min(b, r[id]);     if (b < l[id] || a > r[id]) return 0.0;     double ret = (fim - ini + 1) * 1.0 / (double)(r[id] - l[id] + 1);     return ret;   }   int main() {     double ret = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d , &l[i], &r[i]);     }     int ini = l[0], fim = r[0];     for (int i = 0; i < n; i++) {       ini = min(l[i], ini);       fim = max(r[i], fim);     }     for (int val = ini; val <= fim; val++) {       double prob = 0;       for (int i = 0; i < n; i++) {         double aux3 = Prob(i, val + 1, r[i]);         double aux = 1;         for (int j = 0; j < n; j++) {           if (i == j) continue;           aux *= Prob(j, l[j], val - 1);         }         double aux2 = 1;         for (int j = 0; j < n; j++) {           if (i == j) continue;           aux2 *= Prob(j, l[j], val);         }         aux3 *= (aux2 - aux);         prob += aux3;       }       double p2, aux1, aux2, aux3;       p2 = 0;       for (int i = 0; i < n; i++) {         aux1 = Prob(i, val, val);         for (int j = 0; j < n; j++) {           if (i == j) continue;           aux1 *= Prob(j, l[j], val - 1);         }         p2 += aux1;       }       aux1 = p2;       aux2 = 1;       for (int i = 0; i < n; i++) aux2 *= Prob(i, l[i], val - 1);       aux3 = 1;       for (int i = 0; i < n; i++) aux3 *= Prob(i, l[i], val);       prob += aux3 - aux2 - aux1;       ret += prob * val;     }     printf( %.10lf n , ret);     return 0;   }   