{"id":319,"date":"2017-01-08T08:59:18","date_gmt":"2017-01-08T00:59:18","guid":{"rendered":"http:\/\/kylelv.com\/?p=319"},"modified":"2017-12-22T20:01:38","modified_gmt":"2017-12-22T12:01:38","slug":"bzoj-1610-usaco2008-febline%e8%bf%9e%e7%ba%bf%e6%b8%b8%e6%88%8f","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=319","title":{"rendered":"bzoj 1610: [Usaco2008 Feb]Line\u8fde\u7ebf\u6e38\u620f"},"content":{"rendered":"<p><center><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fdef6c462d5\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fdef6c462d5\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.kylelv.com\/?p=319\/#1610_Usaco2008_FebLine%E8%BF%9E%E7%BA%BF%E6%B8%B8%E6%88%8F\" title=\"1610: [Usaco2008 Feb]Line\u8fde\u7ebf\u6e38\u620f\">1610: [Usaco2008 Feb]Line\u8fde\u7ebf\u6e38\u620f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.kylelv.com\/?p=319\/#Description\" title=\"Description\">Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.kylelv.com\/?p=319\/#Input\" title=\"Input\">Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.kylelv.com\/?p=319\/#Output\" title=\"Output\">Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.kylelv.com\/?p=319\/#Sample_Input\" title=\"Sample Input\">Sample Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.kylelv.com\/?p=319\/#Sample_Output\" title=\"Sample Output\">Sample Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.kylelv.com\/?p=319\/#HINT\" title=\"HINT\">HINT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/blog.kylelv.com\/?p=319\/#Source\" title=\"Source\">Source<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"1610_Usaco2008_FebLine%E8%BF%9E%E7%BA%BF%E6%B8%B8%E6%88%8F\"><\/span>1610: [Usaco2008 Feb]Line\u8fde\u7ebf\u6e38\u620f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a05 Sec\u00a0\u00a0Memory Limit:\u00a064 MB<\/span><\/center><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>Farmer John\u6700\u8fd1\u53d1\u660e\u4e86\u4e00\u4e2a\u6e38\u620f\uff0c\u6765\u8003\u9a8c\u81ea\u547d\u4e0d\u51e1\u7684\u8d1d\u831c\u3002\u6e38\u620f\u5f00\u59cb\u7684\u65f6 \u5019\uff0cFJ\u4f1a\u7ed9\u8d1d\u831c\u4e00\u5757\u753b\u7740N (2 &lt;= N &lt;= 200)\u4e2a\u4e0d\u91cd\u5408\u7684\u70b9\u7684\u6728\u677f\uff0c\u5176\u4e2d\u7b2ci\u4e2a\u70b9 \u7684\u6a2a\u3001\u7eb5\u5750\u6807\u5206\u522b\u4e3aX_i\u548cY_i (-1,000 &lt;= X_i &lt;=1,000\uff1b -1,000 &lt;= Y_i &lt;= 1,000)\u3002 \u8d1d\u831c\u53ef\u4ee5\u9009\u4e24\u4e2a\u70b9\u753b\u4e00\u6761\u8fc7\u5b83\u4eec\u7684\u76f4\u7ebf\uff0c\u5f53\u4e14\u4ec5\u5f53\u5e73\u9762\u4e0a\u4e0d\u5b58\u5728\u4e0e\u753b\u51fa\u76f4\u7ebf \u5e73\u884c\u7684\u76f4\u7ebf\u3002\u6e38\u620f\u7ed3\u675f\u65f6\u8d1d\u831c\u7684\u5f97\u5206\uff0c\u5c31\u662f\u5979\u753b\u51fa\u7684\u76f4\u7ebf\u7684\u603b\u6761\u6570\u3002\u4e3a\u4e86\u5728\u6e38\u620f \u4e2d\u80dc\u51fa\uff0c\u8d1d\u831c\u627e\u5230\u4e86\u4f60\uff0c\u5e0c\u671b\u4f60\u5e2e\u5979\u8ba1\u7b97\u4e00\u4e0b\u6700\u5927\u53ef\u80fd\u5f97\u5206\u3002<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>* \u7b2c1\u884c: \u8f93\u51651\u4e2a\u6b63\u6574\u6570\uff1aN<\/p>\n<p>* \u7b2c2..N+1\u884c: \u7b2ci+1\u884c\u75282\u4e2a\u7528\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570X_i\u3001Y_i\uff0c\u63cf\u8ff0\u4e86\u70b9i\u7684\u5750\u6807<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u7b2c1\u884c: \u8f93\u51fa1\u4e2a\u6574\u6570\uff0c\u8868\u793a\u8d1d\u831c\u7684\u6700\u5927\u5f97\u5206\uff0c\u5373\u5979\u80fd\u753b\u51fa\u7684\u4e92\u4e0d\u5e73\u884c\u7684\u76f4\u7ebf\u6570<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">4<br \/>\n-1 1<br \/>\n-2 0<br \/>\n0 0<br \/>\n1 1<br \/>\n<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">* \u7b2c1\u884c: \u8f93\u51fa1\u4e2a\u6574\u6570\uff0c\u8868\u793a\u8d1d\u831c\u7684\u6700\u5927\u5f97\u5206\uff0c\u5373\u5979\u80fd\u753b\u51fa\u7684\u4e92\u4e0d\u5e73\u884c\u7684\u76f4\u7ebf\u6570<\/p>\n<p><\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>&nbsp;<\/p>\n<p>4 \u8f93\u51fa\u8bf4\u660e: \u8d1d\u831c\u80fd\u753b\u51fa\u4ee5\u4e0b4\u79cd\u659c\u7387\u7684\u76f4\u7ebf\uff1a-1\uff0c0\uff0c1\/3\u4ee5\u53ca1\u3002<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Source\"><\/span>Source<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5bf9\u659c\u7387\u6392\u5e8f<\/p>\n<pre class=\"lang:c++ decode:true \">#include&lt;cstdio&gt;\r\n#include&lt;algorithm&gt; \r\nusing namespace std;\r\ndouble k[20001],e=1e-7;\r\nint n,x[201],y[201],cnt,sum=1;\r\nint main()\r\n{\r\n    scanf(\"%d\",&amp;n);\r\n    for(int i=0;i&lt;n;i++) scanf(\"%d%d\",&amp;x[i],&amp;y[i]);\r\n    for(int i=0;i&lt;n;i++) \r\n    for(int j=i+1;j&lt;n;j++)\r\n    {\r\n        if(abs(x[i]-x[j])&gt;e) k[cnt++]=(y[i]-y[j])*1.0\/(x[i]-x[j]);\r\n        else k[cnt++]=1e15;\r\n    }\r\n    sort(k,k+cnt);\r\n    for(int i=1;i&lt;cnt;i++) if(k[i]-k[i-1]&gt;e) sum++;\r\n    printf(\"%d\\n\",sum);\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1610: [Usaco2008 Feb]Line\u8fde\u7ebf\u6e38\u620f Time Limit:\u00a05 Sec\u00a0\u00a0Memory [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[20,8],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-20","tag-8"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/319\/revisions\/320"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}