{"id":289,"date":"2019-09-25T15:07:51","date_gmt":"2019-09-25T07:07:51","guid":{"rendered":"http:\/\/www.guanhaobo.cn\/?p=289"},"modified":"2019-09-25T15:07:51","modified_gmt":"2019-09-25T07:07:51","slug":"%e6%b4%9b%e8%b0%b7-p1024-%e4%b8%80%e5%85%83%e4%b8%89%e6%ac%a1%e6%96%b9%e7%a8%8b%e6%b1%82%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.guanhaobo.cn\/?p=289","title":{"rendered":"\u6d1b\u8c37 P1024 \u2014 \u4e00\u5143\u4e09\u6b21\u65b9\u7a0b\u6c42\u89e3"},"content":{"rendered":"<h3>\u9898\u76ee\u63cf\u8ff0<\/h3>\n<p>\u6709\u5f62\u5982\uff1aax^3+bx^2+cx+d=0 \u8fd9\u6837\u7684\u4e00\u4e2a\u4e00\u5143\u4e09\u6b21\u65b9\u7a0b\u3002\u7ed9\u51fa\u8be5\u65b9\u7a0b\u4e2d\u5404\u9879\u7684\u7cfb\u6570(a\uff0cb\uff0cc\uff0cd \u5747\u4e3a\u5b9e\u6570)\uff0c\u5e76\u7ea6\u5b9a\u8be5\u65b9\u7a0b\u5b58\u5728\u4e09\u4e2a\u4e0d\u540c\u5b9e\u6839(\u6839\u7684\u8303\u56f4\u5728-100\u81f3100\u4e4b\u95f4)\uff0c\u4e14\u6839\u4e0e\u6839\u4e4b\u5dee\u7684\u7edd\u5bf9\u503c> =1\u3002\u8981\u6c42\u7531\u5c0f\u5230\u5927\u4f9d\u6b21\u5728\u540c\u4e00\u884c\u8f93\u51fa\u8fd9\u4e09\u4e2a\u5b9e\u6839(\u6839\u4e0e\u6839\u4e4b\u95f4\u7559\u6709\u7a7a\u683c)\uff0c\u5e76\u7cbe\u786e\u5230\u5c0f\u6570\u70b9\u540e2\u4f4d\u3002<br \/>\n\u3000\u3000\u63d0\u793a\uff1a\u8bb0\u65b9\u7a0bf(x)=0\uff0c\u82e5\u5b58\u57282\u4e2a\u6570x1\u548cx2\uff0c\u4e14x1&lt; x2\uff0cf(x1)*(x2)&lt; 0\uff0c\u5219\u5728(x1\uff0cx2)\u4e4b\u95f4\u4e00\u5b9a\u6709\u4e00\u4e2a\u6839\u3002<\/p>\n<h3>\u9898\u76ee\u94fe\u63a5<\/h3>\n<p><a href=\"https:\/\/www.luogu.org\/problem\/P1024\" title=\"https:\/\/www.luogu.org\/problem\/P1024\">https:\/\/www.luogu.org\/problem\/P1024<\/a><\/p>\n<h3>\u8f93\u5165\u6570\u636e<\/h3>\n<p>\u8f93\u5165\u8be5\u65b9\u7a0b\u4e2d\u5404\u9879\u7684\u7cfb\u6570  (a \uff0c b \uff0c c \uff0c d  \u5747\u4e3a\u5b9e\u6570)\uff0c<\/p>\n<h3>\u8f93\u51fa\u6570\u636e<\/h3>\n<p>\u7531\u5c0f\u5230\u5927\u4f9d\u6b21\u5728\u540c\u4e00\u884c\u8f93\u51fa\u8fd9\u4e09\u4e2a\u5b9e\u6839(\u6839\u4e0e\u6839\u4e4b\u95f4\u7559\u6709\u7a7a\u683c)\uff0c\u5e76\u7cbe\u786e\u5230\u5c0f\u6570\u70b9\u540e 2 \u4f4d\u3002<\/p>\n<h3>\u6837\u4f8b\u8f93\u5165<\/h3>\n<p><code>1 -5 -4 20<\/code><\/p>\n<h3>\u6837\u4f8b\u8f93\u51fa<\/h3>\n<p><code>-2.00 2.00 5.00<\/code><\/p>\n<h3>\u9898\u76ee\u5206\u6790<\/h3>\n<p>\u6839\u7684\u8303\u56f4\u662f-100\u81f3100\uff0c\u6240\u4ee5\u4ece\u5de6\u5230\u53f3\u679a\u4e3e\uff0c\u627e\u5230\u7b2c\u4e00\u4e2a right \u4f7f\u5f97 f(-100) * f(right) &lt; 0 \uff0c\u7136\u540e\u5728 -100 \u5230 right \u4e4b\u95f4\u8fdb\u884c\u4e8c\u5206\u67e5\u627e\uff0c\u5bfb\u627e\u6839\u7684\u503c\u3002\u540c\u7406\u5728\u627e\u51fa\u53e6\u5916\u4e24\u4e2a\u533a\u95f4\uff0c\u8fdb\u884c\u4e8c\u5206\u5373\u53ef\u3002<br \/>\n\u5bfb\u627e\u533a\u95f4\u65f6\uff0c\u6bcf\u6b21\u679a\u4e3e\u7684\u5927\u5c0f\u53ea\u8981\u5c0f\u4e8e1\u5373\u53ef\uff0c\u56e0\u4e3a\u6839\u4e0e\u6839\u4e4b\u5dee\u7684\u7edd\u5bf9\u503c>=1<\/p>\n<h3>AC\u4ee3\u7801<\/h3>\n<pre><code class=\"language-cpp line-numbers\">#include &lt;bits\/stdc++.h&gt;\nusing namespace std;\n\ndouble a, b, c, d;\n\ndouble f(double x)\n{\n    return a * x * x * x + b * x * x + c * x + d;\n}\n\ndouble GetRight(double left)\n{\n    for (double i = left; i &lt;= 100; i += 0.9)\n    {\n        if (f(left) * f(i) &lt; 0)\n        {\n            return i;\n        }\n    }\n    return -999; \/\/\u6ca1\u6709\u627e\u5230\n}\n\nint main()\n{\n    double left, right, left2, right2, mid;\n    int t = 0; \/\/\u89e3\u7684\u4e2a\u6570\n    cin &gt;&gt; a &gt;&gt; b &gt;&gt; c &gt;&gt; d;\n    left = -100;\n    right = GetRight(left);\n    left2 = left, right2 = right;\n    while (left2 &lt;= right2)\n    {\n        mid = (left2 + right2) \/ 2;\n        if (fabs(f(mid)) &lt; 0.00001)\n        {\n            t++;\n            if (t &gt; 1)\n                printf(\" \");\n            printf(\"%.2f\", mid);\n            left = right;\n            if (t == 3)\n                break;\n            right = GetRight(left);\n            left2 = left, right2 = right;\n            continue;\n        }\n        if (f(mid) * f(left2) &gt; 0)\n            left2 = mid;\n        else\n            right2 = mid;\n    }\n    return 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0 \u6709\u5f62\u5982\uff1aax^3+bx^2+cx+d=0 \u8fd9\u6837\u7684\u4e00\u4e2a\u4e00\u5143\u4e09\u6b21\u65b9\u7a0b\u3002\u7ed9\u51fa\u8be5\u65b9\u7a0b\u4e2d\u5404\u9879\u7684\u7cfb\u6570(a\uff0cb\uff0cc [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[32,53,56],"class_list":["post-289","post","type-post","status-publish","format-standard","hentry","category-algo","tag-32","tag-53","tag-56"],"_links":{"self":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts\/289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=289"}],"version-history":[{"count":0,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts\/289\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}