{"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":"题目描述","value":{"format":"MD","content":"集训队里的土豪经常无故给大家发钱,今天,山西土豪闲来无事又想给大家发钱,然而钱不能乱发,他决定通过游戏的方式发给大家。\nn个队员围成一圈,山西土豪给了每个人两个数字,每个队员在以这两个数字为上下界概率均等地随机选择了一个数字(即如果某个人的两个数字分别是2和5则这个人会在2,3,4,5之间随机选择一个数,概率相等均为1/4)\n山西土豪非常喜欢一个质数p,如果两个相邻的人(1与2相邻,2与3相邻,...,n-1与n相邻,n与1相邻)的数字的乘积是p的倍数,则山西土豪会给这两人每人1000元\n求所有人得到的钱总和的期望"}},{"title":"输入","value":{"format":"MD","content":"第一行两个数n,p(3\u003c\u003dn\u003c\u003d100000,2\u003c\u003dp\u003c\u003d1e9)\n接下来n行,每行两个数a,b,表示山西土豪给这个人的数字(1\u003c\u003da\u003c\u003db\u003c\u003d1e9)"}},{"title":"输出","value":{"format":"MD","content":"输出一个数,表示大家得到的钱总和的期望\n与正确答案的绝对误差或是相对误差在1e-6以内均视为正确"}},{"title":"样例输入1","value":{"format":"MD","content":"3 2\n1 2\n420 421\n420420 420421"}},{"title":"样例输出1","value":{"format":"MD","content":"4500"}},{"title":"样例输入2","value":{"format":"MD","content":"3 5\n1 4\n2 3\n11 14"}},{"title":"样例输出2","value":{"format":"MD","content":"0"}}]}