{"id":366,"date":"2018-11-07T17:02:24","date_gmt":"2018-11-07T09:02:24","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=366"},"modified":"2018-11-07T17:02:24","modified_gmt":"2018-11-07T09:02:24","slug":"lp2831-noip2016-%e6%84%a4%e6%80%92%e7%9a%84%e5%b0%8f%e9%b8%9f","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2018\/11\/07\/lp2831-noip2016-%e6%84%a4%e6%80%92%e7%9a%84%e5%b0%8f%e9%b8%9f\/","title":{"rendered":"lp2831 NOIP2016 \u6124\u6012\u7684\u5c0f\u9e1f"},"content":{"rendered":"<p>\u770b\u5230\\(n&lt;=18\\)\uff0c\u5f88\u5bb9\u6613\u53ef\u4ee5\u60f3\u5230\u72b6\u538b\\(DP\\)\u3002<br \/>\n\u6700\u5927\u529b\u7684\u505a\u6cd5\u5c31\u662f\uff0c\u679a\u4e3e\u539f\u96c6\u5408\u548c\u8f6c\u79fb\u7684\u76ee\u7684\u96c6\u5408\uff0c\u7136\u540e\u8003\u8651\u4e00\u6761\u629b\u7269\u7ebf\u80fd\u5426\u7a7f\u8fc7\u5176\u4e2d\u7684\u6240\u6709\u70b9\u3002<br \/>\n\u4f46\u662f\u8fd9\u6837\u7684\u590d\u6742\u5ea6\u663e\u7136\u662f\u4e0d\u53ef\u63a5\u53d7\u7684\uff0c\u8003\u8651\u4f18\u5316\u3002<br \/>\n\u6613\u77e5\uff0c\u4e09\u70b9\u786e\u5b9a\u4e00\u6761\u629b\u7269\u7ebf\uff0c\u6545\u800c\u5728\u7ed9\u5b9a\\(c=0\\)\u7684\u65f6\u5019\uff0c\u786e\u5b9a\u4e24\u70b9\u5373\u53ef\u786e\u5b9a\u7b2c\u4e09\u70b9\u3002\u5177\u4f53\u7684\u65b9\u7a0b\u7ec4\u662f\uff1a<br \/>\n$$a=\\frac{x_{j}*y_{i}-x_{i}*y{j}}{x_{i}*x_{j}*(x_{i}-x_{j})}$$<br \/>\n$$b=\\frac{y_{i}}{x_{i}}-a*x_{i}$$<br \/>\n\u4ece\u800c\u6211\u4eec\u53ef\u4ee5\u9884\u5904\u7406\u51fa\uff0c\u901a\u8fc7\u67d0\u4e24\u4e2a\u70b9\u7684\u629b\u7269\u7ebf\u901a\u8fc7\u7684\u70b9\u7684\u96c6\u5408\uff0c\u7136\u540e\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u72b6\u6001\uff0c\u9009\u62e9\u54ea\u4e24\u4e2a\u70b9\u62d3\u5c55\u5373\u53ef\u3002<br \/>\n\u4f46\u8fd9\u4e2a\u65f6\u5019\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u662f\\(O(T*n^2*2^n)\\)\uff0c\u5bf9\u4e8e\u8f83\u5927\u7684\u6570\u636e\u8fd8\u662f\u5f88\u96be\u901a\u8fc7\u7684\u3002<br \/>\n\u8fd9\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u7b2c\u4e00\u4e2a\u9009\u62e9\u7684\u70b9\u662f\u53ef\u4ee5\u56fa\u5b9a\u7684\uff0c\u4e5f\u5c31\u662f\u7b2c\u4e00\u4e2a\u53ef\u9009\u62e9\u7684\u70b9\u3002\u56e0\u4e3a\u5982\u679c\u9009\u62e9\u5176\u4ed6\u70b9\u5f00\u59cb\u62d3\u5c55\u7684\u8bdd\uff0c\u5230\u6700\u540e\u4f9d\u7136\u8981\u62d3\u5c55\u90a3\u4e2a\u70b9\u3002<br \/>\n\u90a3\u4e48\u5c31\u6210\u529f\u5730\u5c06\u590d\u6742\u5ea6\u538b\u7f29\u5230\u4e86\\(O(T*n*2^n)\\)\uff0c\u8fd9\u65f6\u5019\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e86\u3002<br \/>\nPS:\u51e1\u662fDouble\u7684\u9898\u90fd\u5e94\u8be5\u6ce8\u610f\u7cbe\u5ea6\u3002<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"cpp\">#include&lt;iostream&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;cstring&gt;\r\nusing namespace std;\r\n#define eps 1E-6\r\nint n,m;\r\nint f[1&lt;&lt;18],A[20][20];\r\ndouble x[20],y[20];\r\ninline int lwbt(const int &amp;_X){\r\n    return _X&amp;-_X;\r\n}\r\ninline int Min(const int &amp;_X,const int &amp;_Y){\r\n    return _X&lt;_Y?_X:_Y;\r\n}\r\ninline int cnt(int _X){\r\n    int rt=0;\r\n    while(_X&amp;1){\r\n        ++rt;\r\n        _X&gt;&gt;=1;\r\n    }\r\n    return rt;\r\n}\r\nvoid init(){\r\n    scanf(\"%d%d\",&amp;n,&amp;m);\r\n    for(int i=0;i&lt;n;++i){\r\n        scanf(\"%lf%lf\",&amp;x[i],&amp;y[i]);\r\n    }\r\n    double a,b;\r\n    for(int i=0;i&lt;n;++i){\r\n        for(int j=i;j&lt;n;++j){\r\n            if(x[i]-x[j]&lt;=eps&amp;&amp;x[i]-x[j]&gt;=-eps){\r\n                if(!(y[i]-y[j]&lt;=eps&amp;&amp;y[i]-y[j]&gt;=-eps)){\r\n                    A[i][j]=0;\r\n                    continue;\r\n                }else{\r\n                    A[i][j]=(1&lt;&lt;i)|(1&lt;&lt;j);\r\n                    continue;\r\n                }\r\n            }\r\n            a=(x[j]*y[i]-x[i]*y[j])\/(x[i]*x[j]*(x[i]-x[j]));\r\n            b=y[i]\/x[i]-a*x[i];\r\n            A[i][j]=0;\r\n            if(a&gt;=-eps){\r\n                continue;\r\n            }\r\n            for(int k=0;k&lt;n;++k){\r\n                if(a*x[k]*x[k]+b*x[k]-y[k]&lt;=eps&amp;&amp;a*x[k]*x[k]+b*x[k]-y[k]&gt;=-eps){\r\n                    A[i][j]|=(1&lt;&lt;k);\r\n                }\r\n            }\r\n        }\r\n    }\r\n    \/*\r\n    for(int i=0;i&lt;n;++i){\r\n        for(int j=0;j&lt;n;++j){\r\n            printf(\"%d \",A[i][j]);\r\n        }\r\n        puts(\"\");\r\n    }\r\n    *\/\r\n    const int MAX=1&lt;&lt;n;\r\n    int loc;\r\n    memset(f,0x3f,sizeof(f));\r\n    f[0]=0;\r\n    \r\n    for(int i=0;i&lt;MAX;++i){\r\n        loc=cnt(i);\r\n        for(int j=loc;j&lt;n;++j){\r\n            f[i|A[loc][j]]=Min(f[i|A[loc][j]],f[i]+1);\r\n        }\r\n    }\r\n    printf(\"%d\\n\",f[MAX-1]);\r\n}\r\nint main(){\r\n    int T;\r\n    scanf(\"%d\",&amp;T);\r\n    while(T--){\r\n        init();\r\n    }\r\n    return 0;\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u770b\u5230\\(n&lt;=18\\)\uff0c\u5f88\u5bb9\u6613\u53ef\u4ee5\u60f3\u5230\u72b6\u538b\\(DP\\)\u3002 \u6700\u5927\u529b\u7684\u505a\u6cd5\u5c31\u662f\uff0c\u679a\u4e3e\u539f\u96c6\u5408\u548c\u8f6c\u79fb\u7684\u76ee\u7684\u96c6\u5408\uff0c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2018\/11\/07\/lp2831-noip2016-%e6%84%a4%e6%80%92%e7%9a%84%e5%b0%8f%e9%b8%9f\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp2831 NOIP2016 \u6124\u6012\u7684\u5c0f\u9e1f\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,34,7,8,39,6,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/366"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=366"}],"version-history":[{"count":1,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/366\/revisions"}],"predecessor-version":[{"id":367,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/366\/revisions\/367"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=366"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}