func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   double prob[maxn];   int main() {     ios::sync_with_stdio(false);     int n, p;     while (cin >> n >> p) {       int l, r;       for (int i = 0; i < n; ++i) {         cin >> l >> r;         prob[i] = (double)(r / p - (l - 1) / p) / (r + 1 - l);       }       double sum = 0;       for (int i = 0; i < n; ++i) {         int j = (i + 1) % n;         sum += 1.0 - (1 - prob[i]) * (1 - prob[j]);       }       printf( %.8lf n , sum * 2000);     }     return 0;   }   