func_code_string: #include <bits/stdc++.h>   using namespace std;   long double chance[100005];   int main() {     int n, p;     while (cin >> n >> p) {       memset(chance, 0, sizeof chance);       long double tmp;       for (int i = 0; i < n; i++) {         int a, b;         cin >> a >> b;         int tem = b / p - (a - 1) / p;         tmp = (long double)tem / (b - a + 1);         chance[i] = tmp;       }       long double ans = 0;       for (int i = 1; i < n; i++) {         ans += chance[i] + chance[i - 1] - chance[i] * chance[i - 1];       }       ans += chance[0] + chance[n - 1] - chance[n - 1] * chance[0];       cout << fixed << setprecision(10) << ans * 2000.0 << endl;     }     return 0;   }   