{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"Problem Statement","value":{"format":"MD","content":"Marry Christmas!\n\nJimmy Rich, a rich guy, would like to give people who solve algorithm problems some Christmas gift. For that, what\u0027s better than just handing out money?!\n\nJimmy asks up to $N$ ($3 \\le N \\le 10^5$) people to sit around a table, such that Persons $i$ and $i + 1$ are neighbours, and Persons $N$ and $1$ are neighbours as well.\n\nThen, Jimmy will think of his favourite prime number $p$. For each $1 \\le i \\le N$, the $i$-th person will randomly and uniformly draw a single integer $s_i$ in the range $[l_i,r_i]$ (both ends inclusive, and subject to $1\\le l_i\\le r_i\\le 10^9$).\n\nFinally, for any **neighbouring** people $i$ and $j$, if $s_i\\cdot s_j$ is **divisible** by $p$, then Jimmy Rich will give $\\$1000$ to Person $i$, and another $\\$1000$ to Person $j$.\n\nWhat is the **expected amount of money** that Jimmy Rich has to spend for this event? i.e., find expected value."}},{"title":"Input","value":{"format":"MD","content":"\u003cp\u003eThe first line of the input contains two space-separated integers \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eN\u003c/i\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ep\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e3 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 100 000, 2 ≤ \u003ci\u003ep\u003c/i\u003e ≤ 10\u003csup class\u003d\"upper-index\"\u003e9\u003c/sup\u003e\u003c/span\u003e)\u0026nbsp;— the number of people sitting around the table and Jimmy Rich\u0027s favourite prime number. It is guaranteed that \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ep\u003c/i\u003e\u003c/span\u003e is prime, you do not have to check for this condition.\u003c/p\u003e\u003cp\u003eThe \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/span\u003e-th of the following \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eN\u003c/i\u003e\u003c/span\u003e lines contains information about \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/span\u003e-th person\u0026nbsp;— two space-separated integers \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003el\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003er\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003el\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e ≤ \u003ci\u003er\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e ≤ 10\u003csup class\u003d\"upper-index\"\u003e9\u003c/sup\u003e\u003c/span\u003e), the range of numbers that person \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/span\u003e can randomly select. Remember that \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e is chosen equiprobably among all integers from \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003el\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e to \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003er\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e, inclusive.\u003c/p\u003e"}},{"title":"Output","value":{"format":"MD","content":"Output a single real number — the expected number of dollars that Jimmy Rich will hand out during this event. Your answer will be considered correct if its absolute or relative error does not exceed $10^{-6}$\u003c/span\u003e."}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2 23\n115 118\n114514 114515\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1000.0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Explanation 1","value":{"format":"MD","content":"There are eight possible pairs of neighbours:\n* $[115, 114514]$, satisfies condition, Jimmy Rich pays $\\$1000$ to both people.\n* $[116, 114514]$, does NOT satisfy the condition, Jimmy Rich does not pay anyone.\n* $[117, 114514]$, does NOT satisfy the condition, Jimmy Rich does not pay anyone.\n* $[118, 114514]$, does NOT satisfy the condition, Jimmy Rich does not pay anyone.\n* $[115, 114515]$, satisfies condition, Jimmy Rich pays $\\$1000$ to both people.\n* $[116, 114515]$, does NOT satisfy the condition, Jimmy Rich does not pay anyone.\n* $[117, 114515]$, does NOT satisfy the condition, Jimmy Rich does not pay anyone.\n* $[118, 114515]$, does NOT satisfy the condition, Jimmy Rich does not pay anyone.\n\nTherefore, the expected amount of money (in dollars) that Jimmy Rich needs to pay is $2000\\cdot \\frac{1}{8} + 2000\\cdot \\frac{1}{8} \u003d 1000$."}},{"title":"Sample 2","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e8 3\n10 11\n26 125\n47 49\n10 90\n23 25\n22 28\n10 20\n40 150\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e7694.516595\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}