{"id":1251,"date":"2019-08-13T15:05:41","date_gmt":"2019-08-13T07:05:41","guid":{"rendered":"https:\/\/cf.mnihyc.com\/blog\/?p=1251"},"modified":"2020-04-23T04:26:13","modified_gmt":"2020-04-22T20:26:13","slug":"yzoj-p4587-%e6%96%90%e6%b3%a2%e9%82%a3%e5%a5%91%e6%95%b0%e5%88%97","status":"publish","type":"post","link":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251","title":{"rendered":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217"},"content":{"rendered":"<h1 style=\"text-align: center;\">YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217<\/h1>\n<p style=\"text-align: center;\">\u65f6\u95f4\u9650\u5236\uff1a1234MS \u00a0\u00a0\u00a0\u00a0 \u5185\u5b58\u9650\u5236\uff1a43210KB<\/p>\n<p style=\"text-align: center;\">\u96be\u5ea6\uff1a<span style=\"color: #ff6600;\">\\(6.5\\)<\/span> \u00a0\u00a0\u00a0\u00a0\u00a0 \uff08\u65e2\u7136\u662f\u81ea\u5df1\u642c\u7684\u9898\u8fd8\u662f\u6b63\u5e38\u4e00\u70b9\u5427w\uff09<\/p>\n<ul>\n<li>\n<h3><strong>\u9898\u76ee\u63cf\u8ff0<\/strong><\/h3>\n<\/li>\n<\/ul>\n<p>\u5b9a\u4e49\u6a21\u610f\u4e49\u4e0b\u7684\u9012\u63a8\u6570\u5217 \\(\\displaystyle f_n=\\left\\{ {\\begin{array}{*{20}{c}} 1&amp;{,n \\le 2}\\\\ {{f_{n &#8211; 1}} + {f_{n &#8211; 2}}}&amp;{,n &gt; 2} \\end{array}} \\right.\\)\uff0c\u5176\u4e2d\u6a21\u6570\u4e3a \\(1000000009\\) \u3002<\/p>\n<p>\u7ed9\u5b9a\u6574\u6570 \\(c\\)\uff08\\(0 \\leq c &lt; 1000000009\\)\uff09\uff0c\u6c42\u51fa\u5b83\u6700\u65e9\u51fa\u73b0\u5728\u6570\u5217\u7684\u54ea\u4e2a\u4f4d\u7f6e\uff0c\u5e76\u8f93\u51fa\u4e0b\u6807\u3002<\/p>\n<p>\u82e5 \\(c\\) \u6c38\u8fdc\u4e0d\u4f1a\u51fa\u73b0\u5728\u6b64\u6570\u5217\u7684\u4efb\u4e00\u4f4d\u7f6e\uff0c\u5219\u8f93\u51fa \\(-1\\) \u3002<\/p>\n<ul>\n<li class=\"problem-ae-cke-label\">\n<h3><strong>\u8f93\u5165\u683c\u5f0f<\/strong><\/h3>\n<\/li>\n<\/ul>\n<p>\u591a\u7ec4\u6570\u636e\u3002<\/p>\n<p>\u7b2c\u4e00\u884c\u4e00\u4e2a\u6b63\u6574\u6570 \\(T\\) \uff08\\(0 &lt; T \\leq 100\\)\uff09 \u8868\u793a \\(T\\) \u7ec4\u6570\u636e\u3002<\/p>\n<p>\u63a5\u4e0b\u6765 \\(T\\) \u884c\u6bcf\u884c\u4e00\u4e2a\u6570\u8868\u793a\u6bcf\u7ec4\u6570\u636e\u7684 \\(c\\) \u3002<\/p>\n<ul>\n<li class=\"problem-ae-cke-label\">\n<h3><strong>\u8f93\u51fa\u683c\u5f0f<\/strong><\/h3>\n<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e\u6bcf\u7ec4\u6570\u636e\uff0c\u8f93\u51fa\u4e00\u884c\u4e00\u4e2a\u6570\u8868\u793a\u7b54\u6848\u3002<\/p>\n<ul>\n<li class=\"problem-ae-cke-label\">\n<h3><strong>\u6837\u4f8b\u8f93\u5165<\/strong><\/h3>\n<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true \">2\r\n987\r\n321<\/pre>\n<ul>\n<li class=\"problem-ae-cke-label\">\n<h3><strong>\u6837\u4f8b\u8f93\u51fa<\/strong><\/h3>\n<\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">16\r\n-1<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Source\uff1a BZOJ 5104<\/p>\n<p><!--more--><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5728\u5176\u4ed6\u5730\u65b9\u5077\u5077\u85cf\u4e86\u70b9\u79c1\u8d27www\uff0c\u7136\u800c\u8fd9\u91cc\u6ca1\u6709<del>\uff08\u4e0d\u9700\u8981\u85cf\uff09<\/del><\/p>\n<p>&nbsp;<\/p>\n<p>\u7b80\u7ea6\u6982\u8ff0\uff1a\u6709\u516c\u5f0f \\(\\displaystyle f_n=\\frac{1}{\\sqrt5}\\left(\\frac{1+\\sqrt5}{2}\\right)^n &#8211; \\frac{1}{\\sqrt5}\\left(\\frac{1-\\sqrt5}{2}\\right)^n\\) \uff0c\u53ef\u4ee5\u5957\u7528 BSGS \u4ee5\u53ca Cipolla \u89e3\u51fa \\(n\\) \u3002<\/p>\n<p>\u6781\u81f4\u5185\u5bb9\uff1a<\/p>\n<ul>\n<li>\n<h3>Section A<\/h3>\n<\/li>\n<\/ul>\n<p>\u9996\u5148\uff0c\\(f_n\\) \u7684\u901a\u9879\u516c\u5f0f\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u6570\u5b66\u6784\u9020\u5f97\u5230\u3002<\/p>\n<p>\u56e0\u4e3a\u4e00\u9636\u7ebf\u6027\u5e38\u7cfb\u6570\u9f50\u6b21\u9012\u63a8\u7684\u901a\u9879\u516c\u5f0f\u4e3a\u7b49\u6bd4\u6570\u5217\uff0c\u6240\u4ee5\u540c\u7406\u8bbe \\(t, q\\)\uff0c\u4f7f\u5f97 \\(\\displaystyle f_n-tf_{n-1} = q\\left(f_{n-1}-tf_{n-2}\\right)\\) \u3002<\/p>\n<p>\u5c55\u5f00\u6574\u7406\u5f97 \\(\\displaystyle f_n = \\left(q+t\\right)f_{n-1}-qtf_{n-2}\\) \uff0c\u5373 \\(\\displaystyle \\left\\{ {\\begin{array}{*{20}{c}}{q + t = 1}\\\\{qt =\u00a0 &#8211; 1}\\end{array}} \\right.\\) \u3002<\/p>\n<p>\u6784\u9020\u4e8c\u6b21\u51fd\u6570 \\(x^2-x-1=0\\) \uff0c\u7531\u97e6\u8fbe\u5b9a\u7406\u53ef\u77e5 \\(q, t\\) \u5206\u522b\u4e3a\u6b64\u65b9\u7a0b\u4e24\u6839\uff0c\u5373 \\(\\displaystyle \\frac{1+\\sqrt5}{2}\\) \u6216 \\(\\displaystyle \\frac{1-\\sqrt5}{2}\\) \u3002<\/p>\n<p>\u7136\u540e\u5957\u5f88\u591a\u4e2a\u7b49\u6bd4\u6570\u5217\u6c42\u548c\u516c\u5f0f\uff0c\u6216\u8005\u76f4\u63a5\u8bbe \\(\\displaystyle f_n = ax_1^n + bx_2^n\\) \u4ee3\u5165\u7279\u6b8a\u503c\u89e3\u65b9\u7a0b\u7ec4\uff0c\u90fd\u53ef\u4ee5\u5f97\u51fa\u00a0\\(\\displaystyle f_n=\\frac{1}{\\sqrt5}\\left(\\frac{1+\\sqrt5}{2}\\right)^n &#8211; \\frac{1}{\\sqrt5}\\left(\\frac{1-\\sqrt5}{2}\\right)^n\\) \u3002<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\n<h3><span style=\"color: black;\">Section B<\/span><\/h3>\n<\/li>\n<\/ul>\n<p>\u63a5\u4e0b\u6765\u5bf9\u8fd9\u4e2a\u516c\u5f0f\u8fdb\u884c\u4e00\u70b9\u5904\u7406\u3002<\/p>\n<p>\u8bbe \\(c=f_n\\)\uff0c\\(\\displaystyle t=\\frac{1+\\sqrt5}{2}\\) \uff0c\u5219\u53ef\u77e5 <span style=\"font-size: 16px;\">\\(\\displaystyle \\frac{1-\\sqrt5}{2} = -\\frac{1}{t}\\)<\/span> \uff0c\u6240\u4ee5\u6709\uff1a \\(\\displaystyle \\sqrt 5 c = {\\left( t \\right)^n} &#8211; {\\left( { &#8211; {1 \\over t}} \\right)^n}\\) \u3002<\/p>\n<p>\u6362\u5143\uff0c\u518d\u8bbe \\(x=t^n\\) \uff0c\u5219\u6709\uff1a\u00a0\\(\\displaystyle \\sqrt 5 c = x &#8211; {\\left( { &#8211; 1} \\right)^n}\\frac{1}{x}\\) \u3002<\/p>\n<p>\u518d\u6574\u7406\uff0c\u53ef\u5f97\u4ee5 \\(x\\) \u4e3a\u4e3b\u5143\u7684\u4e00\u5143\u4e8c\u6b21\u65b9\u7a0b \\(\\displaystyle x^2 &#8211; \\sqrt5cx &#8211; {\\left( { &#8211; 1} \\right)^n} = 0\\) \u3002<\/p>\n<p>\u6b64\u65b9\u7a0b \\(\\displaystyle \\Delta = 5c^2 + 4\\left( { &#8211; 1} \\right)^n\\) \uff0c\u7136\u540e\u5957\u7528\u4e00\u5143\u4e8c\u6b21\u65b9\u7a0b\u6c42\u6839\u516c\u5f0f\u53ef\u5f97 <span style=\"font-size: 16px;\">\\(\\displaystyle x=\\frac{{\\sqrt 5 c \\; \\pm \\sqrt \\Delta\u00a0 }}{2}\\)<\/span> \u3002<\/p>\n<p>\u516c\u5f0f\u4e2d\u5176\u4e2d\u6d89\u53ca\u5230 \\(\\sqrt \\Delta\\) \u7684\u90e8\u5206\uff0c\u53ef\u4ee5\u91c7\u7528 Cipolla \u6c42\u89e3\u3002<\/p>\n<p>\u5176\u4e2d \\(\\left(-1\\right)^n\\) \u53ef\u4ee5\u6839\u636e \\(n\\) \u7684\u5947\u5076\u6027\u5206\u6210 \\(-1\\) \u548c \\(1\\) \u4e24\u79cd\u53d6\u503c\uff0c\u5206\u7c7b\u8ba8\u8bba\u3002<\/p>\n<p>\u53c8\u56e0\u4e3a \\(t^n = x\\) \uff0c\u6240\u4ee5\u8dd1 BSGS \u6c42\u51fa \\(n\\) \u7684\u6700\u5c0f\u6b63\u6574\u6570\u89e3\uff0c\u5e76\u4e0e\u5176\u4ed6\u60c5\u51b5\u6c42\u51fa\u7684 \\(n\\) \u53d6\u6700\u5c0f\u5373\u53ef\u5f97\u51fa\u7b54\u6848\u3002<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\n<h3>Section C<\/h3>\n<\/li>\n<\/ul>\n<p>\u4f1a BSGS \u7684\u4eba\u53ef\u4ee5\u53bb AC \u4e86\u3002<\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Baby-step_giant-step\">BSGS (Baby-step giant-step)<\/a> \u662f\u6c42\u89e3\u6a21\u610f\u4e49\u4e0b\u65b9\u7a0b \\(\\displaystyle {a^x} \\equiv b\\pmod p\\) \uff08\u8fd9\u91cc\u5047\u8bbe \\(p\\) \u4e3a\u8d28\u6570\uff09\u4e2d \\(x\\) \u7684\u6700\u5c0f\u6b63\u6574\u6570\u89e3\u7684\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6700\u5c0f\u6b63\u6574\u6570\u89e3 \\(x\\) \u4e0d\u4f1a\u8d85\u8fc7 \\(p-1\\) \u3002<\/p>\n<p>\u82e5 \\(x \\geq p\\) \uff0c\u90a3\u4e48\u53ef\u4ee5\u8bbe \\(\\displaystyle x=i\\left(p-1\\right)+j\\) \uff0c\u5176\u4e2d \\(i \\geq 1, 0 \\leq j &lt; p-1\\) \u3002<\/p>\n<p>\u90a3\u4e48\u6709 \\(\\displaystyle {a^x} = {a^{i\\left(p-1\\right) + j}} = {a^{i\\left(p-1\\right)}}{a^j} \\equiv b\\pmod p\\) \u3002<\/p>\n<p>\u56e0\u4e3a \\(p\\) \u4e3a\u8d28\u6570\uff0c\\(a &lt; p\\) \uff0c\u6240\u4ee5\u7531\u8d39\u9a6c\u5c0f\u5b9a\u7406\u5f97 \\(\\displaystyle a^{p-1} \\equiv 1\\pmod p\\) \u3002<\/p>\n<p>\u6240\u4ee5\u6709 \\(\\displaystyle {a^x} = {a^{ip}}{a^j} \\equiv {a^j} \\equiv b\\pmod p\\) \uff0c\u5373 \\(\\displaystyle a^x \\equiv a^{x \\bmod \\left(p-1\\right)} \\pmod p\\) \u3002<\/p>\n<p>\u6240\u4ee5\u53ea\u9700\u8981\u5728 \\((0, p-1]\\) \u5185\u5bfb\u627e \\(x\\) \u5373\u53ef\u3002<\/p>\n<p>\u66b4\u529b\u679a\u4e3e\u4e0d\u73b0\u5b9e\uff0c\u5c1d\u8bd5\u5c06 \\(p\\) \u5206\u6210\u4e24\u90e8\u5206\uff0c\u5373\u8bbe \\(\\displaystyle s=\\lceil \\sqrt p \\rceil\\)\uff0c\u90a3\u4e48 \\(x\\) \u53ef\u4ee5\u5206\u89e3\u4e3a \\(is-j\\) \uff0c\u5176\u4e2d \\(0 &lt; i \\leq s, 0 \\leq j &lt; s\\) \u3002<\/p>\n<p>\u90a3\u4e48\u6709 \\(\\displaystyle {a^x} = {a^{is &#8211; j}} \\equiv b\\pmod p\\) \uff0c\u5373 \\(\\displaystyle {a^{is}} \\equiv b{a^j}\\pmod p\\) \u3002<\/p>\n<p>\u679a\u4e3e \\(j\\) \uff0c\u628a\u7b49\u53f7\u53f3\u8fb9\u7684\u503c\u5b58\u5230 hash_table\uff08\\(O(1)\\)\uff09 \u6216 std::map \uff08\\(O(\\log s)\\)\uff09\u4e2d\uff0c\u7136\u540e\u679a\u4e3e \\(i\\) \u914d\u5bf9\u3002<\/p>\n<p>\u56e0\u4e3a \\(i, j\\) \u6700\u591a\u53ea\u5230 \\(\\displaystyle s=\\lceil \\sqrt p \\rceil\\) \uff0c\u6240\u4ee5\u590d\u6742\u5ea6\u4e3a\u00a0\\(O(\\sqrt p)\\) \u6216 \\(O(\\sqrt p \\log p)\\)\u3002<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\n<h3>Section D<\/h3>\n<\/li>\n<\/ul>\n<p>\u4f1a Cipolla \u7684\u4eba\u53ef\u4ee5\u53bb AC \u4e86\u3002<\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Cipolla%27s_algorithm\">Cipolla<\/a> \u662f\u4e00\u79cd\u6c42\u89e3\u4e8c\u6b21\u5269\u4f59\u7684\u9ad8\u6548\u7b97\u6cd5\u3002<\/p>\n<p>\u867d\u7136\u6c42\u89e3\u4e8c\u6b21\u5269\u4f59\u4e5f\u53ef\u4ee5\u4f7f\u7528 BSGS\uff0c\u4f46\u662f\u4f7f\u7528 Cipolla \u65f6\u95f4\u590d\u6742\u5ea6\u4f1a\u6bd4\u4e4b\u4f18\u79c0<s>\uff08\u4e5f\u4e0d\u77e5\u9053\u6211\u80fd\u4e0d\u80fd\u6210\u529f\u5361\u6389\uff09<\/s>\u3002<\/p>\n<p>\u5bf9\u4e8e\u5947\u8d28\u6570 \\(p\\) \u53ca\u6574\u6570 \\(n\\)\uff0c\u82e5\u5b58\u5728\u6574\u6570 \\(x, 0 \\leq x &lt; p\\) \u4e14\u6ee1\u8db3 \\(\\displaystyle x^2 \\equiv n\\pmod p\\) \uff0c\u90a3\u4e48 \\(n\\) \u5c31\u79f0\u4f5c\u5728\u6a21 \\(p\\) \u610f\u4e49\u4e0b\u7684\u4e8c\u6b21\u5269\u4f59\u3002<\/p>\n<p>\u5b9a\u4e49\u6570\u57df \\(\\displaystyle \\mathbb {F}_p\\) \u5305\u542b \\([0, p-1]\\) \u4e2d\u7684\u6574\u6570\uff0c\u5176\u4e2d\u7684\u8fd0\u7b97\u5747\u5728\u6a21\u610f\u4e49\u4e0b\u8fdb\u884c\u3002\u82e5\u65e0\u7279\u6b8a\u8bf4\u660e\uff0c\u4e0b\u5217\u64cd\u4f5c\u5747\u5728 \\(\\displaystyle \\mathbb {F}_p\\) \u4e0b\u8fdb\u884c\u3002<\/p>\n<p>\u5148\u6765\u8bc1\u660e\u51e0\u4e2a\u5f15\u7406\u3002<\/p>\n<p><span style=\"font-size: 14px;\">\\(Lemma.1\\)<\/span>\uff1a\u5bf9\u4e8e\u65b9\u7a0b \\(\\displaystyle x^2 \\equiv n \\pmod p\\) \uff0c\u603b\u5171\u53ea\u6709 \\(\\displaystyle \\frac{p-1}{2}\\) \u4e2a \\(n\\)\uff08\\(0&lt;n&lt;p\\)\uff09 \u4f7f\u5f97 \\(x\\) \u6709\u89e3\u3002<\/p>\n<p><span style=\"font-size: 14px;\">\\(Proof\\)<\/span>\uff1a\u5047\u8bbe\u5b58\u5728\u4e24\u4e2a\u4e0d\u540c\u7684\u6570 \\(u, v\\) \u4f7f\u5f97 \\(\\displaystyle u^2 \\equiv v^2 \\pmod p\\) \uff0c\u90a3\u4e48\u6709 \\(\\displaystyle p\\; |\\; \\left(u^2-v^2\\right)\\) \uff0c\u5373 \\(\\displaystyle p\\; |\\; \\left(u+v\\right)\\left(u-v\\right)\\) \u3002<\/p>\n<p style=\"margin-left: 40px;\">\u7531\u4e8e \\(\\displaystyle p\\; \\not |\\; \\left(u-v\\right)\\)\uff0c\u6240\u4ee5\u00a0\\(\\displaystyle p\\; |\\; \\left(u+v\\right)\\) \uff0c\u5373 \\(\\displaystyle u+v \\equiv 0 \\pmod p\\) \u3002<\/p>\n<p style=\"margin-left: 40px;\">\u6240\u4ee5 \\((0,p-1]\\) \u4e2d \\(\\displaystyle x^2 \\equiv \\left(p-x\\right)^2 \\pmod p\\)\uff0c\u6709\u4e14\u53ea\u6709 \\(\\displaystyle \\frac{p-1}{2}\\) \u5bf9\u8fd9\u6837\u7684\u6570\uff0c\u6240\u4ee5\u6709\u4e14\u53ea\u6709 \\(\\displaystyle \\frac{p-1}{2}\\) \u79cd\u4e0d\u540c\u7684 \\(n\\)\uff0c\u5f97\u8bc1\u3002<\/p>\n<p><span style=\"font-size: 14px;\">\\(Lemma.2\\)<\/span>\uff1a\u5b9a\u4e49 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Legendre_symbol\">\u52d2\u8ba9\u5fb7\u7b26\u53f7 (Legendre symbol)<\/a> \\(\\displaystyle \\left(\\frac{a}{p}\\right)=\\begin{cases}1,&amp;a\\text{\u5728\u6a21$p$\u610f\u4e49\u4e0b\u662f\u4e8c\u6b21\u5269\u4f59}\\\\-1,&amp;a\\text{\u5728\u6a21$p$\u610f\u4e49\u4e0b\u662f\u975e\u4e8c\u6b21\u5269\u4f59}\\\\0,&amp;a\\equiv0\\pmod p\\end{cases}\\)<\/p>\n<p style=\"margin-left: 40px;\">\u7136\u540e\u6709 <span style=\"font-size: 16px;\">\\(\\displaystyle \\left(\\frac{a}{p}\\right)\\equiv a^{\\frac{p-1}{2}}\\pmod p\\)<\/span> \uff08\u5373 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Euler%27s_criterion\">\u6b27\u62c9\u5224\u522b\u6cd5 (Euler&#8217;s criterion)<\/a>\uff09\u3002<\/p>\n<p><span style=\"font-size: 14px;\">\\(Proof\\)<\/span>\uff1a\u5f53 \\(a\\) \u5728\u6a21 \\(p\\) \u610f\u4e49\u4e0b\u662f\u4e8c\u6b21\u5269\u4f59\uff0c\u5373 <span style=\"font-size: 16px;\">\\(\\displaystyle \\left(\\frac{a}{p}\\right)\\equiv a^{\\frac{p-1}{2}} \\equiv 1\\pmod p\\)<\/span> \u65f6\uff1a\u8bbe \\(\\displaystyle x^2 \\equiv a\\pmod p\\) \uff0c\u6240\u4ee5\u6709 <span style=\"font-size: 16px;\">\\(\\displaystyle x^{p-1} \\equiv a^{\\frac{p-1}{2}} \\equiv 1\\pmod p\\) <\/span>\u3002<\/p>\n<p style=\"margin-left: 40px;\">\u6839\u636e\u8d39\u9a6c\u5c0f\u5b9a\u7406\u53ef\u77e5\u8fd9\u6837\u7684 \\(x\\) \u5b58\u5728\uff0c\u6545\u539f\u547d\u9898\u5f97\u8bc1\u3002<\/p>\n<p style=\"margin-left: 40px;\">\u5f53 \\(a\\) \u5728\u6a21 \\(p\\) \u610f\u4e49\u4e0b\u4e0d\u662f\u4e8c\u6b21\u5269\u4f59\uff0c\u5373 <span style=\"font-size: 16px;\">\\(\\displaystyle \\left(\\frac{a}{p}\\right)\\equiv a^{\\frac{p-1}{2}} \\equiv -1\\pmod p\\)<\/span> \u65f6\uff1a\u8bbe \\(\\displaystyle x^2 \\equiv a\\pmod p\\) \uff0c\u6240\u4ee5\u6709 <span style=\"font-size: 16px;\">\\(\\displaystyle x^{p-1} \\equiv a^{\\frac{p-1}{2}} \\equiv -1\\pmod p\\) <\/span>\u3002<\/p>\n<p style=\"margin-left: 40px;\">\u6839\u636e\u8d39\u9a6c\u5c0f\u5b9a\u7406\u53ef\u77e5\u8fd9\u6837\u7684 \\(x\\) \u4e0d\u5b58\u5728\uff0c\u6545\u539f\u547d\u9898\u5f97\u8bc1\u3002<\/p>\n<p style=\"margin-left: 40px;\">\u5f53 <span style=\"font-size: 16px;\">\\(\\displaystyle \\left(\\frac{a}{p}\\right)\\equiv a^{\\frac{p-1}{2}} \\equiv 0\\pmod p\\)<\/span> \u65f6\uff1a\u663e\u7136\u3002<\/p>\n<p>\u7531\u4e8e\u8fd9\u4e2a\u7b97\u6cd5\u6784\u9020\u5de7\u5999\uff0c\u6240\u4ee5\u5148\u4ecb\u7ecd\u5176\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n<p>1\uff0c\u7ed9\u5b9a \\(n\\) \uff0c\u82e5 \\(\\displaystyle \\left(\\frac{n}{p}\\right) \\neq 1\\) \uff0c\u5219\u53ef\u4ee5\u76f4\u63a5\u7ed9\u51fa\u7b54\u6848\u3002<\/p>\n<p>2\uff0c\u968f\u673a \\(a\\) \u76f4\u5230 \\(\\displaystyle \\left(\\frac{a^2-n}{p}\\right) = -1\\) \u3002\u7531 \u5f15\u74061 \u53ef\u77e5\uff0c\u671f\u671b\u968f\u673a\u6b21\u6570\u4e3a \\(2\\)\u3002<\/p>\n<p>3\uff0c\u6269\u5c55\u81f3 \\(\\displaystyle \\mathbb{F}_{p^2}\\)\uff0c\u5e76\u628a \\(\\displaystyle \\sqrt{a^2-n}\\) \u4f5c\u4e3a\u201c\u7b2c\u4e8c\u6761\u6570\u8f74\u201d\u7684\u5355\u4f4d\u957f\u5ea6\uff08\u53ef\u7c7b\u6bd4\u590d\u6570\uff09\u3002\u8fd9\u6837\uff0c\u6b64\u57df\u4e2d\u7684\u6570\u53ef\u4ee5\u8868\u793a\u4e3a \\(\\displaystyle a+b\\omega\\) \uff0c\u5176\u4e2d \\(\\displaystyle \\omega^2 = a^2-n\\) \uff0c\u5e76\u4e14\u6b64\u6570\u57df\u4f9d\u7136\u6ee1\u8db3\u4ea4\u6362\u5f8b\u3001\u7ed3\u5408\u5f8b\u4ee5\u53ca\u5206\u914d\u5f8b\u3002<\/p>\n<p><span style=\"color: #ffffff;\"><s>Q\uff1a\u4e3a\u4ec0\u4e48\u8d34\u56fe\uff1f\u00a0\u00a0 A\uff1a\u56e0\u4e3a\u6211\u770b\u4e0d\u61c2<\/s><\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1254 size-full\" src=\"https:\/\/cf.mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png\" alt=\"\" width=\"1001\" height=\"599\" srcset=\"https:\/\/cf.mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png 1001w, https:\/\/cf.mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221-300x180.png 300w, https:\/\/cf.mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221-768x460.png 768w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>4\uff0c\u5c06 \\(x\\) \u4e5f\u6269\u5c55\u81f3 \\(\\displaystyle \\mathbb{F}_{p^2}\\)\uff0c<span style=\"font-size: 16px;\">\\(\\displaystyle x \\equiv \\left(a+\\omega\\right)^{\\frac{p+1}{2}} \\pmod p \\)<\/span> \uff0c\u53d6 \\(x\\)\u201c\u7b2c\u4e00\u6761\u6570\u8f74\u201d\u4e2d\u7684\u90e8\u5206\u5373\u4e3a\u7b54\u6848\u3002<\/p>\n<p>\u8981\u8bc1\u660e\u6216\u8005\u641e\u61c2\u8fd9\u4e2a\u662f\u5728\u8bf4\u4ec0\u4e48\uff0c\u8fd8\u9700\u8981\u518d\u8bc1\u660e\u4e00\u4e9b\u5f15\u7406\u3002<\/p>\n<p><span style=\"font-size: 14px;\">\\(Lemma.3\\)<\/span>\uff1a<span style=\"font-size: 16px;\">\\(\\displaystyle \\omega^p \\equiv &#8211; \\omega \\pmod p\\)<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\\(Proof\\)<\/span>\uff1a<span style=\"font-size: 16px;\">\\(\\displaystyle {\\omega ^p} \\equiv \\omega\u00a0 \\cdot {\\omega ^{p &#8211; 1}} \\equiv \\omega {\\left( {{\\omega ^2}} \\right)^{\\frac{{p &#8211; 1}}{2}}} \\equiv \\omega {\\left( {{a^2} &#8211; n} \\right)^{\\frac{{p &#8211; 1}}{2}}} \\equiv\u00a0 &#8211; \\omega \\pmod p\\)<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\\(Lemma.4\\)<\/span>\uff1a<span style=\"font-size: 16px;\">\\(\\displaystyle \\left(a+b\\right)^p \\equiv a^p+b^p \\pmod p\\)<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\\(Proof\\)<\/span>\uff1a\u6839\u636e\u4e8c\u9879\u5f0f\u5b9a\u7406\u5c55\u5f00\uff0c\u6709 <span style=\"font-size: 16px;\">\\(\\displaystyle \\left(a+b\\right)^p \\equiv \\sum\\limits_{i=0}^pC_p^ia^ib^{p-i} \\pmod p\\)<\/span> \uff0c\u7531\u4e8e\u5f53 \\(0&lt;i&lt;p\\) \u65f6 \\(\\displaystyle C_p^i \\equiv 0 \\pmod p\\)\uff0c\u6240\u4ee5\u5f97\u8bc1\u3002<\/p>\n<p>\u73b0\u5728\u5df2\u7ecf\u53ef\u4ee5\u6765\u8bc1\u660e\u300c\u6b65\u9aa44\u300d\u4e86\u3002<\/p>\n<p>\u6839\u636e\u53d9\u8ff0\uff0c\u5df2\u77e5 <span style=\"font-size: 16px;\">\\(\\displaystyle x \\equiv \\left(a+\\omega\\right)^{\\frac{p+1}{2}} \\pmod p\\)<\/span>\uff0c\u5373\u00a0\\(\\displaystyle x^2 \\equiv \\left(a+\\omega\\right)^{p+1} \\pmod p\\) \u3002<\/p>\n<p>\u6839\u636e \u5f15\u74064 \uff0c\u6709 \\(\\displaystyle \\left(a+\\omega\\right)^{p+1} \\equiv \\left(a+\\omega\\right)\\left(a+\\omega\\right)^p \\equiv \\left(a+\\omega\\right)\\left(a^p+\\omega^p\\right) \\pmod p\\) \u3002<\/p>\n<p>\u6839\u636e\u8d39\u9a6c\u5c0f\u5b9a\u7406 \\(\\displaystyle a^p \\equiv a \\pmod p\\) \u4ee5\u53ca \u5f15\u74063\uff0c\u53ef\u5f97 \\(\\displaystyle \\left(a+\\omega\\right)\\left(a^p+\\omega^p\\right) \\equiv \\left(a+\\omega\\right)\\left(a-\\omega\\right) \\pmod p\\) \u3002<\/p>\n<p>\u6240\u4ee5\u6709 \\(\\displaystyle x^2 \\equiv \\left(a+\\omega\\right)\\left(a-\\omega\\right) \\equiv a^2-\\omega^2 \\equiv a^2-\\left(a^2-n\\right) \\equiv n \\pmod p\\) \uff0c\u53ef\u8bc1 \\(x\\) \u4e3a\u6b64\u65b9\u7a0b\u7684\u4e00\u4e2a\u5408\u6cd5\u89e3\u3002<\/p>\n<p>\u7b49\u7b49\uff0c\u521a\u521a\u300c\u6b65\u9aa44\u300d\u91cc\u4e0d\u662f\u8bf4\u300c\u53d6 \\(x\\)\u201c\u7b2c\u4e00\u6761\u6570\u8f74\u201d\u4e2d\u7684\u90e8\u5206\u5373\u4e3a\u7b54\u6848\u300d\u5417\uff1f\u4e0a\u9762\u7684\u8bc1\u660e\u90fd\u662f\u5728 \\(\\displaystyle \\mathbb{F}_{p^2}\\) \u4e2d\u8fdb\u884c\u7684\uff0c\u600e\u4e48\u80fd\u76f4\u63a5\u53d6\u5176\u4e2d\u7684\u4e00\u90e8\u5206\uff08\u4fdd\u8bc1\u89e3\u53ef\u4ee5\u88ab\u538b\u7f29\u5230 \\(\\displaystyle \\mathbb{F}_{p}\\)\uff09\uff1f<\/p>\n<p>\u8fd9\u91cc\u5c31\u8981\u63d0\u5230\u795e\u5947\u7684 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lagrange%27s_theorem_%28number_theory%29\">\u62c9\u683c\u6717\u65e5\u5b9a\u7406 (Lagrange&#8217;s theorem)<\/a> \uff0c\u90fd\u77e5\u9053 \\(n\\) \u6b21\u65b9\u7a0b\u6700\u591a\u6709 \\(n\\) \u4e2a\u89e3\uff0c\u540c\u65f6\u8fd9\u4e2a\u7ed3\u8bba\u5728\u6a21\u610f\u4e49\u4e0b\u4ecd\u662f\u6210\u7acb\u7684\u3002<\/p>\n<p>\u6240\u4ee5\u5728 \\(\\displaystyle \\mathbb{F}_{p}\\) \u4e2d\uff0c\u4e14 \\(n\\) \u4e3a\u6a21 \\(p\\) \u610f\u4e49\u4e0b\u7684\u4e8c\u6b21\u5269\u4f59\u65f6\uff0c\u65b9\u7a0b \\(\\displaystyle x^2 \\equiv n \\pmod p\\) \u5373 \\(\\displaystyle x^2-n \\equiv 0 \\pmod p\\) \u6700\u591a\u5b58\u5728\u4e24\u6839 \\(\\displaystyle x_0, x_1 \\in \\mathbb{F}_{p}\\) \u3002<\/p>\n<p>\u7531\u62c9\u683c\u6717\u65e5\u5b9a\u7406\u53ef\u77e5\u5373\u4f7f\u6269\u5c55\u5230 \\(\\displaystyle \\mathbb{F}_{p^2}\\) \uff0c\u6b64\u65b9\u7a0b\u4ecd\u7136\u6700\u591a\u53ea\u4f1a\u6709\u4e24\u4e2a\u6839\uff0c\u5e76\u4e14\u8fd9\u4e24\u6839\u5c31\u201c\u76f8\u5f53\u4e8e\u662f\u201d\u539f\u6765\u7684 \\(x_0, x_1\\)\uff0c\u6240\u4ee5\u8fd9\u4e24\u6839\u4e00\u5b9a\u53ef\u4ee5\u88ab\u538b\u7f29\u5230 \\(\\displaystyle \\mathbb{F}_{p}\\) \u4e2d\uff0c\u5373 \\(\\displaystyle a+b\\omega\\) \u4e2d \\(b=0\\) \u3002<\/p>\n<p>\uff08\u53ef\u7c7b\u6bd4\u590d\u6570\u8fd0\u7b97\/\u5f00\u6839\uff09<\/p>\n<p>\u6700\u540e\uff0c\u5206\u6790\u8fc7\u7a0b\u53ef\u77e5\u6b64\u7b97\u6cd5\u65f6\u95f4\u590d\u6742\u5ea6\u53ef\u8fd1\u4f3c\u4e8e \\(O(\\log p)\\) \u3002<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\n<h3>Section ?<\/h3>\n<\/li>\n<\/ul>\n<p>\u672c\u9898\u603b\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a\uff1a\\(\\displaystyle O\\left( \\sqrt p + \\log p \\right)\\)\u3002<\/p>\n<p>\u6d89\u53ca\u7b97\u6cd5\uff1aBSGS + Cipolla + Time constant<\/p>\n<p>\/\/ std::map \u6216\u8005\u591a\u4e2a log \u6216\u8005\u54ea\u91cc\u5e38\u6570\u6bd4\u8f83\u5927\u90fd\u4f1a\u88ab\u5361\u6389<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true \">#include &lt;cstdio&gt;\r\n#include &lt;cstdlib&gt;\r\n#include &lt;cstring&gt;\r\n#include &lt;climits&gt;\r\n#include &lt;ctime&gt;\r\n\r\n#define _min(_a_,_b_) ((_a_)&lt;(_b_)?(_a_):(_b_))\r\n\r\n#define MOD 1000000009\r\n#define SQRT5MOD 383008016 \/\/ sqrt(5)\r\n#define INV2MOD 500000005 \/\/ 1\/2 (mod)\r\n#define TMOD 691504013 \/\/ (sqrt(5)+1)\/2\r\n\r\nstruct _pair\r\n{\r\n\tint first,second;\r\n\t_pair(int f,int s) :first(f),second(s) {};\r\n};\r\ninline _pair _make_pair(register int f,register int s)\r\n{\r\n\treturn (_pair){f,s};\r\n}\r\n\r\ninline int _pow(register int base,register int b)\r\n{\r\n\tregister int ans=1;\r\n\twhile(b)\r\n\t{\r\n\t\tif(b&amp;1)\r\n\t\t\tans=(long long)ans * base %MOD;\r\n\t\tbase=(long long)base * base %MOD;\r\n\t\tb&gt;&gt;=1;\r\n\t}\r\n\treturn ans;\r\n}\r\n\r\nint _cm_w; \/\/ unit of Fp^2\r\nstruct _cm\r\n{\r\n\tint a,b; \/\/ a+bw, w &lt;-&gt; _cm_w\r\n\t_cm(int a=0,int b=0) :a(a),b(b) {}\r\n\tinline _cm operator * (const _cm&amp;o)const\r\n\t{\r\n\t\t_cm ans;\r\n\t\tans.a=((long long)a * o.a %MOD + (long long)b * o.b %MOD * _cm_w %MOD) %MOD;\r\n\t\tans.b=((long long)a * o.b %MOD + (long long)b * o.a %MOD) %MOD;\r\n\t\treturn ans;\r\n\t}\r\n};\r\n\r\ninline _cm _cm_pow(_cm base,register int b)\r\n{\r\n\t_cm ans=1;\r\n\twhile(b)\r\n\t{\r\n\t\tif(b&amp;1)\r\n\t\t\tans=ans * base;\r\n\t\tbase=base * base;\r\n\t\tb&gt;&gt;=1;\r\n\t}\r\n\treturn ans;\r\n}\r\n\r\ninline _pair GetRoot(register int n)\r\n{\r\n\tif(!n)\r\n\t\treturn _make_pair(0,0);\r\n\tif(_pow(n, (MOD-1)&gt;&gt;1) == MOD-1)\r\n\t\treturn _make_pair(-1,-1);\r\n\t\r\n\tregister int a;\r\n\twhile(true)\r\n\t{\r\n\t\ta=rand()%MOD;\r\n\t\t_cm_w=((long long)a * a %MOD - n + MOD) %MOD;\r\n\t\tif(_pow(_cm_w, (MOD-1)&gt;&gt;1) == MOD-1)\r\n\t\t\tbreak;\r\n\t}\r\n\t\r\n\t_cm ans=_cm_pow((_cm){a,1},(MOD+1)&gt;&gt;1);\r\n\treturn _make_pair(ans.a, (MOD - ans.a) %MOD);\r\n}\r\n\r\nstruct _hash\r\n{\r\n\t#define _MAX_LEN 31624\r\n\t#define _HASH_MOD 176503\r\n\tint hcnt,hhead[_HASH_MOD+1],hnext[_MAX_LEN+1],harr[_MAX_LEN+1],hval[_MAX_LEN+1];\r\n\tinline void clear()\r\n\t{\r\n\t\thcnt=0,memset(hhead,0,sizeof(hhead));\r\n\t}\r\n\tinline int&amp; operator [](const int&amp;arr)\r\n\t{\r\n\t\tregister int idx=arr%_HASH_MOD;\r\n\t\t++hcnt,hnext[hcnt]=hhead[idx],hhead[idx]=hcnt,harr[hcnt]=arr;\r\n\t\treturn hval[hcnt];\r\n\t}\r\n\tinline int at(register int arr)const\r\n\t{\r\n\t\tregister int idx=arr%_HASH_MOD;\r\n\t\tfor(register int j=hhead[idx];j;j=hnext[j])\r\n\t\t\tif(harr[j]==arr)\r\n\t\t\t\treturn hval[j];\r\n\t\treturn 0;\r\n\t}\r\n}hash;\r\n\r\ninline int BSGS(register int a,register int c)\r\n{\r\n\thash.clear();\r\n\tregister int sp=__builtin_sqrt(MOD)+1;\r\n\tfor(register int j=0,pwaj=1;j&lt;sp;j++)\r\n\t\thash[(long long)c * pwaj %MOD]=j+1,\r\n\t\tpwaj=(long long)pwaj * a %MOD;\r\n\tregister int ans=0;\r\n\tfor(register int i=1,aisp=(long long)_pow(a,sp),pwaisp=aisp;i&lt;=sp;\r\n\t\ti++,pwaisp=(long long)pwaisp * aisp %MOD)\r\n\t\tif((ans=hash.at(pwaisp)))\r\n\t\t\treturn i*sp-(ans-1);\r\n\treturn -1;\r\n}\r\n\r\ninline int GetAns(register int c,register int sd,register bool left2)\r\n{\r\n\tregister int t=TMOD,sc=(long long)c * SQRT5MOD %MOD;\r\n\tregister int x=(long long)((sc + sd) %MOD + MOD) %MOD * INV2MOD %MOD;\r\n\tregister int n=BSGS(t,x);\r\n\t\/\/printf(\"%d^(%d)=%d\\n\",t,n,x);\r\n\tif(!n || n==-1 || n%2!=left2)\r\n\t\treturn INT_MAX;\r\n\treturn n;\r\n}\r\n\r\nint main()\r\n{\r\n\/\/freopen(\"test.in\",\"r\",stdin);\r\nsrand(time(NULL));\r\nint _T;scanf(\"%d\",&amp;_T);\r\nwhile(_T--)\r\n{\r\n\tint c;scanf(\"%d\",&amp;c);\r\n\t\r\n\tregister int ans=INT_MAX,tans;\r\n\t\r\n\tregister int n=((long long)c * c %MOD * 5 %MOD - 4 + MOD) %MOD;\r\n\t_pair root = GetRoot(n);\r\n\tif(root.first != -1)\r\n\t\ttans=GetAns(c,root.first,1),ans=_min(ans,tans);\r\n\tif(root.second!=-1 &amp;&amp; root.second!=root.first)\r\n\t\ttans=GetAns(c,root.second,1),ans=_min(ans,tans);\r\n\t\r\n\tn=((long long)c * c %MOD * 5 %MOD + 4) %MOD;\r\n\troot = GetRoot(n);\r\n\tif(root.first != -1)\r\n\t\ttans=GetAns(c,root.first,0),ans=_min(ans,tans);\r\n\tif(root.second!=-1 &amp;&amp; root.second!=root.first)\r\n\t\ttans=GetAns(c,root.second,0),ans=_min(ans,tans);\r\n\t\r\n\tprintf(\"%d\\n\",(ans==INT_MAX ? -1 : ans));\r\n}\r\n\treturn 0;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 \u65f6\u95f4\u9650\u5236\uff1a1234MS \u00a0\u00a0\u00a0\u00a0 \u5185\u5b58\u9650\u5236\uff1a43210KB \u96be\u5ea6\uff1a \u00a0\u00a0\u00a0 &hellip; <a href=\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41,106,109,79],"tags":[],"class_list":["post-1251","post","type-post","status-publish","format-standard","hentry","category-proa","category-bsgs","category-quadratic-residue","category-matrixfastpow"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 - mnihyc&#039;s Blog<\/title>\n<meta name=\"description\" content=\"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 \u65f6\u95f4\u9650\u5236\uff1a1234MS \u00a0\u00a0\u00a0\u00a0 \u5185\u5b58\u9650\u5236\uff1a43210KB \u96be\u5ea6\uff1a \u00a0\u00a0\u00a0\u00a0\u00a0 \uff08\u65e2\u7136\u662f\u81ea\u5df1\u642c\u7684\u9898\u8fd8\u662f\u6b63\u5e38\u4e00\u70b9\u5427w\uff09 \u9898\u76ee\u63cf\u8ff0 \u5b9a\u4e49\u6a21\u610f\u4e49\u4e0b\u7684\u9012\u63a8\u6570\u5217 (displaystyle f_n=left{ {begin{array}{*{20}{c}}\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 - mnihyc&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 \u65f6\u95f4\u9650\u5236\uff1a1234MS \u00a0\u00a0\u00a0\u00a0 \u5185\u5b58\u9650\u5236\uff1a43210KB \u96be\u5ea6\uff1a \u00a0\u00a0\u00a0\u00a0\u00a0 \uff08\u65e2\u7136\u662f\u81ea\u5df1\u642c\u7684\u9898\u8fd8\u662f\u6b63\u5e38\u4e00\u70b9\u5427w\uff09 \u9898\u76ee\u63cf\u8ff0 \u5b9a\u4e49\u6a21\u610f\u4e49\u4e0b\u7684\u9012\u63a8\u6570\u5217 (displaystyle f_n=left{ {begin{array}{*{20}{c}}\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251\" \/>\n<meta property=\"og:site_name\" content=\"mnihyc&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-13T07:05:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-22T20:26:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png\" \/>\n<meta name=\"author\" content=\"mnihyc\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@mnihyc\" \/>\n<meta name=\"twitter:site\" content=\"@mnihyc\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"mnihyc\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#article\",\"isPartOf\":{\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251\"},\"author\":{\"name\":\"mnihyc\",\"@id\":\"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/61e167d6d591fdd20dcfee2cf848a751\"},\"headline\":\"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217\",\"datePublished\":\"2019-08-13T07:05:41+00:00\",\"dateModified\":\"2020-04-22T20:26:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251\"},\"wordCount\":942,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/61e167d6d591fdd20dcfee2cf848a751\"},\"image\":{\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png\",\"articleSection\":[\"6.0 ~ 7.0\",\"BSGS\",\"\u4e8c\u6b21\u5269\u4f59\",\"\u77e9\u9635\u5feb\u901f\u5e42\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251\",\"url\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251\",\"name\":\"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 - mnihyc&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/mnihyc.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png\",\"datePublished\":\"2019-08-13T07:05:41+00:00\",\"dateModified\":\"2020-04-22T20:26:13+00:00\",\"description\":\"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 \u65f6\u95f4\u9650\u5236\uff1a1234MS \u00a0\u00a0\u00a0\u00a0 \u5185\u5b58\u9650\u5236\uff1a43210KB \u96be\u5ea6\uff1a \u00a0\u00a0\u00a0\u00a0\u00a0 \uff08\u65e2\u7136\u662f\u81ea\u5df1\u642c\u7684\u9898\u8fd8\u662f\u6b63\u5e38\u4e00\u70b9\u5427w\uff09 \u9898\u76ee\u63cf\u8ff0 \u5b9a\u4e49\u6a21\u610f\u4e49\u4e0b\u7684\u9012\u63a8\u6570\u5217 \\\\(\\\\displaystyle f_n=\\\\left\\\\{ {\\\\begin{array}{*{20}{c}}\",\"breadcrumb\":{\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#primaryimage\",\"url\":\"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png\",\"contentUrl\":\"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/mnihyc.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mnihyc.com\/blog\/#website\",\"url\":\"https:\/\/mnihyc.com\/blog\/\",\"name\":\"mnihyc&#039;s Blog\",\"description\":\"Welcome!\",\"publisher\":{\"@id\":\"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/61e167d6d591fdd20dcfee2cf848a751\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mnihyc.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/61e167d6d591fdd20dcfee2cf848a751\",\"name\":\"mnihyc\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8d111f863afc3f98816bc96220f97077d470a96f41088de9f19530fc480f8e72?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8d111f863afc3f98816bc96220f97077d470a96f41088de9f19530fc480f8e72?s=96&d=mm&r=g\",\"caption\":\"mnihyc\"},\"logo\":{\"@id\":\"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 - mnihyc&#039;s Blog","description":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 \u65f6\u95f4\u9650\u5236\uff1a1234MS \u00a0\u00a0\u00a0\u00a0 \u5185\u5b58\u9650\u5236\uff1a43210KB \u96be\u5ea6\uff1a \u00a0\u00a0\u00a0\u00a0\u00a0 \uff08\u65e2\u7136\u662f\u81ea\u5df1\u642c\u7684\u9898\u8fd8\u662f\u6b63\u5e38\u4e00\u70b9\u5427w\uff09 \u9898\u76ee\u63cf\u8ff0 \u5b9a\u4e49\u6a21\u610f\u4e49\u4e0b\u7684\u9012\u63a8\u6570\u5217 (displaystyle f_n=left{ {begin{array}{*{20}{c}}","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251","og_locale":"zh_CN","og_type":"article","og_title":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 - mnihyc&#039;s Blog","og_description":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 \u65f6\u95f4\u9650\u5236\uff1a1234MS \u00a0\u00a0\u00a0\u00a0 \u5185\u5b58\u9650\u5236\uff1a43210KB \u96be\u5ea6\uff1a \u00a0\u00a0\u00a0\u00a0\u00a0 \uff08\u65e2\u7136\u662f\u81ea\u5df1\u642c\u7684\u9898\u8fd8\u662f\u6b63\u5e38\u4e00\u70b9\u5427w\uff09 \u9898\u76ee\u63cf\u8ff0 \u5b9a\u4e49\u6a21\u610f\u4e49\u4e0b\u7684\u9012\u63a8\u6570\u5217 (displaystyle f_n=left{ {begin{array}{*{20}{c}}","og_url":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251","og_site_name":"mnihyc&#039;s Blog","article_published_time":"2019-08-13T07:05:41+00:00","article_modified_time":"2020-04-22T20:26:13+00:00","og_image":[{"url":"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png","type":"","width":"","height":""}],"author":"mnihyc","twitter_card":"summary_large_image","twitter_creator":"@mnihyc","twitter_site":"@mnihyc","twitter_misc":{"\u4f5c\u8005":"mnihyc","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#article","isPartOf":{"@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251"},"author":{"name":"mnihyc","@id":"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/61e167d6d591fdd20dcfee2cf848a751"},"headline":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217","datePublished":"2019-08-13T07:05:41+00:00","dateModified":"2020-04-22T20:26:13+00:00","mainEntityOfPage":{"@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251"},"wordCount":942,"commentCount":0,"publisher":{"@id":"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/61e167d6d591fdd20dcfee2cf848a751"},"image":{"@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#primaryimage"},"thumbnailUrl":"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png","articleSection":["6.0 ~ 7.0","BSGS","\u4e8c\u6b21\u5269\u4f59","\u77e9\u9635\u5feb\u901f\u5e42"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cf.mnihyc.com\/blog\/archives\/1251#respond"]}]},{"@type":"WebPage","@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251","url":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251","name":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 - mnihyc&#039;s Blog","isPartOf":{"@id":"https:\/\/mnihyc.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#primaryimage"},"image":{"@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#primaryimage"},"thumbnailUrl":"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png","datePublished":"2019-08-13T07:05:41+00:00","dateModified":"2020-04-22T20:26:13+00:00","description":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217 \u65f6\u95f4\u9650\u5236\uff1a1234MS \u00a0\u00a0\u00a0\u00a0 \u5185\u5b58\u9650\u5236\uff1a43210KB \u96be\u5ea6\uff1a \u00a0\u00a0\u00a0\u00a0\u00a0 \uff08\u65e2\u7136\u662f\u81ea\u5df1\u642c\u7684\u9898\u8fd8\u662f\u6b63\u5e38\u4e00\u70b9\u5427w\uff09 \u9898\u76ee\u63cf\u8ff0 \u5b9a\u4e49\u6a21\u610f\u4e49\u4e0b\u7684\u9012\u63a8\u6570\u5217 \\(\\displaystyle f_n=\\left\\{ {\\begin{array}{*{20}{c}}","breadcrumb":{"@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cf.mnihyc.com\/blog\/archives\/1251"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#primaryimage","url":"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png","contentUrl":"https:\/\/mnihyc.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-03_2333221.png"},{"@type":"BreadcrumbList","@id":"https:\/\/cf.mnihyc.com\/blog\/archives\/1251#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/mnihyc.com\/blog"},{"@type":"ListItem","position":2,"name":"YZOJ P4587 \u6590\u6ce2\u90a3\u5951\u6570\u5217"}]},{"@type":"WebSite","@id":"https:\/\/mnihyc.com\/blog\/#website","url":"https:\/\/mnihyc.com\/blog\/","name":"mnihyc&#039;s Blog","description":"Welcome!","publisher":{"@id":"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/61e167d6d591fdd20dcfee2cf848a751"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mnihyc.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/61e167d6d591fdd20dcfee2cf848a751","name":"mnihyc","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8d111f863afc3f98816bc96220f97077d470a96f41088de9f19530fc480f8e72?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8d111f863afc3f98816bc96220f97077d470a96f41088de9f19530fc480f8e72?s=96&d=mm&r=g","caption":"mnihyc"},"logo":{"@id":"https:\/\/mnihyc.com\/blog\/#\/schema\/person\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/posts\/1251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/comments?post=1251"}],"version-history":[{"count":1,"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/posts\/1251\/revisions"}],"predecessor-version":[{"id":1707,"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/posts\/1251\/revisions\/1707"}],"wp:attachment":[{"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/media?parent=1251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/categories?post=1251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cf.mnihyc.com\/blog\/wp-json\/wp\/v2\/tags?post=1251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}