#include <bits/stdc++.h>   using namespace std;   int l[100000 + 9], r[100000 + 9];   int n, p;   int main() {     cin >> n >> p;     for (int i = 0; i < n; i++) {       cin >> l[i] >> r[i];     }     double ans = 0;     for (int i = 0; i < n; i++) {       int j = (i + 1) % n;       int div1 = r[i] / p - (l[i] - 1) / p;       int nondiv1 = r[i] - l[i] + 1 - div1;       int div2 = r[j] / p - (l[j] - 1) / p;       int nondiv2 = r[j] - l[j] + 1 - div2;       double nondivs = 1.0 - ((double)nondiv1 / double(r[i] - l[i] + 1)) *                                  ((double)nondiv2 / double(r[j] - l[j] + 1));       ans += nondivs * 2000.0;     }     cout << fixed << setprecision(15) << ans;     return 0;   }   