{"id":26,"date":"2011-10-01T03:39:46","date_gmt":"2011-09-30T19:39:46","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=26"},"modified":"2012-03-04T00:59:17","modified_gmt":"2012-03-03T16:59:17","slug":"%e5%9c%86%e5%b9%b6","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/%e5%9c%86%e5%b9%b6\/","title":{"rendered":"\u5706\u5e76 .. ."},"content":{"rendered":"<p><a href=\"http:\/\/zh.wikipedia.org\/wiki\/%E9%A4%98%E5%BC%A6%E5%AE%9A%E7%90%86\">http:\/\/zh.wikipedia.org\/wiki\/%E9%A4%98%E5%BC%A6%E5%AE%9A%E7%90%86<\/a><br \/>\n<a href=\"http:\/\/www.cnblogs.com\/ch3656468\/archive\/2011\/03\/02\/1969303.html\">http:\/\/www.cnblogs.com\/ch3656468\/archive\/2011\/03\/02\/1969303.html<\/a><br \/>\n<a href=\"http:\/\/hi.baidu.com\/billdu\/blog\/item\/2b162f7bb799affa2e73b331.html\">http:\/\/hi.baidu.com\/billdu\/blog\/item\/2b162f7bb799affa2e73b331.html<\/a><br \/>\n<a href=\" http:\/\/user.qzone.qq.com\/122155302\/blog\/1311607940\">http:\/\/user.qzone.qq.com\/122155302\/blog\/1311607940<\/a><br \/>\n<a href=\" http:\/\/zh.wikipedia.org\/wiki\/%E9%A4%98%E5%BC%A6%E5%AE%9A%E7%90%86\">http:\/\/zh.wikipedia.org\/wiki\/%E9%A4%98%E5%BC%A6%E5%AE%9A%E7%90%86<\/a><\/p>\n<p><!--more--><\/p>\n<h3>\u65b9\u6cd5\u4e00\uff1a\u6570\u503c\u79ef\u5206<\/h3>\n<p>\u9664\u4e86 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Simpson%27s_rule\">Simpson&#8217;s rule <\/a> \u4ee5\u5916\u5e94\u8be5\u8fd8\u6709\u5176\u5b83\uff08\u54ea\u4e9b\uff1f\uff09\u6570\u503c\u79ef\u5206\u7684\u65b9\u6cd5\uff0c\u4f46\u662f\u7531\u4e8e\u8fd9\u65b9\u9762\u6211\u7684\u77e5\u8bc6\u4e0d\u662f\u5f88\u7262\u9760\u5b9e\u5728\u662f\u532e\u4e4f\u554a\u532e\u4e4f\u5c31\u6ca1\u6709\u529e\u6cd5\u5e26\u5927\u5bb6\u8be6\u7ec6\u8ba8\u8bba\u4e86\u3002\u3002\uff08\u3002\u3002\u3002\u3002\uff09<\/p>\n<p>\u3002\u3002 f(x) \u8868\u793a\u539f\u51fd\u6570\uff0cs(x) \u8868\u793a\u5bf9\u8be5\u51fd\u6570\u7684\u4e0d\u5b9a\u79ef\u5206\u3002\u3002<br \/>\n\u90a3\u4e48 Simpson&#8217;s rule \u8868\u8fbe\u9664\u4e86\u5c31\u662f\u8fd9\u4e2a\u3002\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n.. .\r\nDB s(DB l, DB r){\r\n    return (f(l) + 4 * f(m) + f(r)) * (r - l);\r\n}\r\n<\/pre>\n<p>\u3002\u3002\u81f3\u4e8e Sevenkplus \u6240\u63d0\u5230\u7684 \u201c\u81ea\u9002\u5e94 Simpson \u516c\u5f0f\u201d \u5e94\u8be5\u5c31\u662f\u3002\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nDB S(DB l, DB r){\r\n    DB ss = s(l, r), sl = s(l, m), sr = s(m, r);\r\n    if (fabs(ss - sl - sr) &lt; EPS) return sl + sr;\r\n    else return S(l, m) + S(m, r);\r\n}\r\n.\r\n<\/pre>\n<p>\u4e5f\u5c31\u662f\u8bbe\u7f6e\u7cbe\u5ea6\u7136\u540e\u5fae\u5143\u9012\u964d\u4e0b\u53bb\u3002\u3002\u65b9\u6cd5\u7c7b\u4f3c\u4ee5\u524d\u505a\u7684\u67d0\u9053 Usaco \u51e0\u4f55\u9898\u3002\u3002<br \/>\n\u4e0b\u9762\u5177\u4f53\u5bf9\u5706\u5e76\u6765\u8bf4\uff0c\u9996\u5148\u5728\u4e3b\u7a0b\u5e8f\u91cc\u53bb\u5197\u4f59\u3002\u3002\u4e5f\u5c31\u662f\u5ffd\u7565\u9000\u5316\u7684\u5706\uff0c\u7136\u540e\u6309\u534a\u5f84\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\uff0c\u6807\u8bb0\u88ab\u6574\u4e2a\u5305\u542b\u7684\u5706\u3002\u3002\uff08\u8fd9\u4e00\u6b65\u4e5f\u53ef\u4ee5\u4e0d\u8981\u3002\u3002\uff09<\/p>\n<p>\uff08\u5bf9\u4e8e\u53bb\u9664\u88ab\u5305\u542b\u8fd9\u79cd\u504f\u5e8f\u5173\u7cfb\u3002\u3002\u5982\u679c\u88ab\u5305\u542b\u7684\u4e2a\u6570\u9898\u76ee\u52a0\u4ee5\u9650\u5236\u7684\u8bdd\u90a3\u4e48\u53ef\u4ee5\u52a0\u5165\u5e38\u6570\u4f18\u5316\u3002\u3002\u53c2\u89c1 <a href=\"https:\/\/www.shuizilong.com\/house\/archives\/2729\">UVa 10902. Pick-up sticks<\/a>\uff09<\/p>\n<p>\u4e4b\u540e\u518d\u6309\u7167\u6bcf\u4e2a\u5706\u5de6\u7aef\u70b9\u7684\u5750\u6807\u6392\u5e8f\uff0c\u4e4b\u540e\u662f\u4e00\u6b65\u626b\u63cf\u7ebf\u7684\u8fc7\u7a0b\u3002\u3002\u5f97\u5230\u6240\u6709\u8981\u6c42\u7684\u533a\u95f4\u3002\u3002<br \/>\n\u6700\u540e\u662f\u5706\u5e76\u91cc f(x) \u51fd\u6570\u7684\u6c42\u6cd5\u3002\u3002\u67d0\u6a2a\u5750\u6807 x \u70b9\u5904 y \u8f74\u4e0a\u88ab\u8986\u76d6\u7684\u9762\u79ef\u3002\u3002<\/p>\n<p>\u65b9\u6cd5\u662f\u3002\u3002\u4e00\u6b21\u73af\u5f62\u7684\u626b\u63cf\u7ebf\u3002\u3002\u7136\u540e\u8fd9\u91cc\u66b4\u529b\u4e86\u4e00\u70b9\u679a\u4e3e\u4e86\u6bcf\u4e00\u4e2a\u5706\u3002\u3002\u3002<br \/>\n\uff08\u3002\u3002\u3002\u597d\u50cf\u8fd9\u91cc\u5750\u6807\u5f88\u96be\u79bb\u6563\u6389\u3002\u3002\u4e8e\u662f\u6ca1\u6709\u529e\u6cd5\u7528\u5176\u5b83\u4ec0\u4e48\u6570\u636e\u7ed3\u6784\u3002\u3002\u4e0d\u77e5\u9053\u6392\u5e8f\u4e8c\u5206\u4f1a\u4e0d\u4f1a\u6709\u6548\u3002\uff09<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n.. .\r\nvector&lt;pair&lt;DB, DB&gt; &gt; I; \/\/ Interval\r\n#define lbd I&#x5B;i].first\r\n#define rbd I&#x5B;i].second\r\n\r\nDB f(DB xx){\r\n\r\n    CLR(I); REP(i, n){\r\n        DB d = fabs(xx - x&#x5B;i]);\r\n        if (d &lt; r&#x5B;i]) d = sqrt(sqr(r&#x5B;i]) - sqr(d)), I.PB(MP(y&#x5B;i] - d, y&#x5B;i] + d));\r\n    }\r\n\r\n    SRT(I);\r\n\r\n    DB Length = 0, ll = -OO, rr = -OO;\r\n    REP(i, SZ(I)){\r\n        if(rr &lt; lbd) Length += rr - ll, ll = lbd, rr = rbd;\r\n        else checkMax(rr, rbd);\r\n    }\r\n\r\n    return Length += rr - ll;\r\n}\r\n.\r\n<\/pre>\n<h3>\u65b9\u6cd5\u4e8c\uff1aAekdycoin \u7684\u65b9\u6cd5 <\/h3>\n<p>\u3002\u3002\u3002\u6838\u6b66\u7684\u65b9\u6cd5\u3002\u3002\u5e94\u8be5\u5c31\u662f\u6700\u6807\u51c6\u7684\u626b\u63cf\u7ebf\u3002\u3002\u56e0\u4e3a\u5706\u6709\u5f88\u591a\u5f88\u597d\u7684\u6027\u8d28\uff0c\u800c\u4e14\u518d\u7ed3\u5408\u6709\u5411\u9762\u79ef\u4ee3\u7801\u91cf\u8981\u4f4e\u4e8e\u9884\u60f3\u3002\u3002<\/p>\n<p>\u9996\u5148\u5f00\u5c40\u51fa\u88c5\u548c\u4e0a\u4e00\u79cd\u65b9\u6cd5\u4e00\u6837\u3002\u3002\u76f4\u63a5\u8fdb\u5165\u4e3b\u8981\u90e8\u5206\u3002\u3002\u3002<br \/>\n\u3002\u3002\u679a\u4e3e\u6bcf\u4e00\u4e2a\u5706\uff0c\u8ba1\u7b97\u6240\u6709\u5176\u5b83\u5706\u548c\u5b83\u7684\u4ea4\u70b9\u3002\u3002\u8fdb\u884c\u79bb\u6563\u5316\u3002\u3002\u8fd9\u79cd\u73af\u5f62\u79bb\u6563\u5316\u4f1a\u4ea7\u751f\u4e00\u4e9b\u95ee\u9898\u3002\u3002\u53c2\u89c1 <a href=\"https:\/\/www.shuizilong.com\/house\/archives\/1451\">Master Spark<\/a> \u90a3\u652f\u3002\u3002<\/p>\n<p>\u7136\u540e\u5927\u5bb6\u5c31\u90fd\u4f1a\u4e86\u5427\u3002<\/p>\n<p>&#8230; .. . .. .. .. . ..<\/p>\n<p>\u3002\u3002\u5b8c\u6574\u4ee3\u7801\u3002\u3002\u3002\u3002<\/p>\n<pre class=\"brush: cpp; collapse: true; light: false; title: SPOJ CIRU Simpson&#039;s rule; toolbar: true; notranslate\" title=\"SPOJ CIRU Simpson&#039;s rule\">\r\n\/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **\/\r\n\r\n#include &lt;algorithm&gt;\r\n#include &lt;iostream&gt;\r\n#include &lt;iomanip&gt;\r\n#include &lt;sstream&gt;\r\n#include &lt;cstring&gt;\r\n#include &lt;cstdio&gt;\r\n#include &lt;string&gt;\r\n#include &lt;vector&gt;\r\n#include &lt;bitset&gt;\r\n#include &lt;queue&gt;\r\n#include &lt;stack&gt;\r\n#include &lt;cmath&gt;\r\n#include &lt;ctime&gt;\r\n#include &lt;list&gt;\r\n#include &lt;set&gt;\r\n#include &lt;map&gt;\r\n\r\nusing namespace std;\r\n\r\n#define REP(i, n) for (int i=0;i&lt;int(n);++i)\r\n#define FOR(i, a, b) for (int i=int(a);i&lt;int(b);++i)\r\n#define DWN(i, b, a) for (int i=int(b-1);i&gt;=int(a);--i)\r\n#define REP_1(i, n) for (int i=1;i&lt;=int(n);++i)\r\n#define FOR_1(i, a, b) for (int i=int(a);i&lt;=int(b);++i)\r\n#define DWN_1(i, b, a) for (int i=int(b);i&gt;=int(a);--i)\r\n#define REP_C(i, n) for (int n____=int(n),i=0;i&lt;n____;++i)\r\n#define FOR_C(i, a, b) for (int b____=int(b),i=a;i&lt;b____;++i)\r\n#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i&gt;=a____;--i)\r\n#define REP_N(i, n) for (i=0;i&lt;int(n);++i)\r\n#define FOR_N(i, a, b) for (i=int(a);i&lt;int(b);++i)\r\n#define DWN_N(i, b, a) for (i=int(b-1);i&gt;=int(a);--i)\r\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i&lt;=n____;++i)\r\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i&lt;=b____;++i)\r\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i&gt;=a____;--i)\r\n#define REP_1_N(i, n) for (i=1;i&lt;=int(n);++i)\r\n#define FOR_1_N(i, a, b) for (i=int(a);i&lt;=int(b);++i)\r\n#define DWN_1_N(i, b, a) for (i=int(b);i&gt;=int(a);--i)\r\n#define REP_C_N(i, n) for (n____=int(n),i=0;i&lt;n____;++i)\r\n#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i&lt;b____;++i)\r\n#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i&gt;=a____;--i)\r\n#define REP_1_C_N(i, n) for (n____=int(n),i=1;i&lt;=n____;++i)\r\n#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i&lt;=b____;++i)\r\n#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i&gt;=a____;--i)\r\n\r\n#define DO(n) while(n--)\r\n#define DO_C(n) int n____ = n; while(n____--)\r\n#define TO(i, a, b) int s_=a&lt;b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)\r\n#define TO_1(i, a, b) int s_=a&lt;b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)\r\n#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i&lt;j;++i,--j)\r\n#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i&lt;=j;++i,--j)\r\n#define REP_2(i, j, n, m) REP(i, n) REP(j, m)\r\n#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)\r\n\r\n#define ALL(A) A.begin(), A.end()\r\n#define LLA(A) A.rbegin(), A.rend()\r\n#define CPY(A, B) memcpy(A, B, sizeof(A))\r\n#define INS(A, P, B) A.insert(A.begin() + P, B)\r\n#define ERS(A, P) A.erase(A.begin() + P)\r\n#define BSC(A, X) find(ALL(A), X) \/\/ != A.end()\r\n#define CTN(T, x) (T.find(x) != T.end())\r\n#define SZ(A) int(A.size())\r\n#define PB push_back\r\n#define MP(A, B) make_pair(A, B)\r\n\r\n#define Rush int T____; RD(T____); DO(T____)\r\n#pragma comment(linker, &quot;\/STACK:36777216&quot;)\r\n#pragma GCC optimize (&quot;O2&quot;)\r\n#define Ruby system(&quot;ruby main.rb&quot;)\r\n#define Haskell system(&quot;runghc main.hs&quot;)\r\n#define Pascal system(&quot;fpc main.pas&quot;)\r\n\r\ntypedef long long LL;\r\ntypedef double DB;\r\ntypedef unsigned UINT;\r\ntypedef unsigned long long ULL;\r\n\r\ntypedef vector&lt;int&gt; VI;\r\ntypedef vector&lt;char&gt; VC;\r\ntypedef vector&lt;string&gt; VS;\r\ntypedef vector&lt;LL&gt; VL;\r\ntypedef vector&lt;DB&gt; VD;\r\ntypedef set&lt;int&gt; SI;\r\ntypedef set&lt;string&gt; SS;\r\ntypedef set&lt;LL&gt; SL;\r\ntypedef set&lt;DB&gt; SD;\r\ntypedef map&lt;int, int&gt; MII;\r\ntypedef map&lt;string, int&gt; MSI;\r\ntypedef map&lt;LL, int&gt; MLI;\r\ntypedef map&lt;DB, int&gt; MDI;\r\ntypedef map&lt;int, bool&gt; MIB;\r\ntypedef map&lt;string, bool&gt; MSB;\r\ntypedef map&lt;LL, bool&gt; MLB;\r\ntypedef map&lt;DB, bool&gt; MDB;\r\ntypedef pair&lt;int, int&gt; PII;\r\ntypedef pair&lt;int, bool&gt; PIB;\r\ntypedef vector&lt;PII&gt; VII;\r\ntypedef vector&lt;VI&gt; VVI;\r\ntypedef vector&lt;VII&gt; VVII;\r\ntypedef set&lt;PII&gt; SII;\r\ntypedef map&lt;PII, int&gt; MPIII;\r\ntypedef map&lt;PII, bool&gt; MPIIB;\r\n\r\n\r\n\/** I\/O Accelerator **\/\r\n\r\n\/* ... :&quot; We are I\/O Accelerator ... Use us at your own risk ;) ... &quot; .. *\/\r\n\r\ntemplate&lt;class T&gt; inline void RD(T &amp;);\r\ntemplate&lt;class T&gt; inline void OT(const T &amp;);\r\n\r\ninline int RD(){ int x; RD(x); return x;}\r\ntemplate&lt;class T&gt; inline T&amp; _RD(T &amp;x){ RD(x); return x;}\r\ninline void RC(char &amp;c){scanf(&quot; %c&quot;, &amp;c);}\r\ninline void RS(char *s){scanf(&quot;%s&quot;, s);}\r\n\r\ntemplate&lt;class T0, class T1&gt; inline void RD(T0 &amp;x0, T1 &amp;x1){RD(x0), RD(x1);}\r\ntemplate&lt;class T0, class T1, class T2&gt; inline void RD(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2){RD(x0), RD(x1), RD(x2);}\r\ntemplate&lt;class T0, class T1, class T2, class T3&gt; inline void RD(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2, T3 &amp;x3){RD(x0), RD(x1), RD(x2), RD(x3);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4&gt; inline void RD(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2, T3 &amp;x3, T4 &amp;x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5&gt; inline void RD(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2, T3 &amp;x3, T4 &amp;x4, T5 &amp;x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5, class T6&gt; inline void RD(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2, T3 &amp;x3, T4 &amp;x4, T5 &amp;x5, T6 &amp;x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}\r\ntemplate&lt;class T0, class T1&gt; inline void OT(T0 &amp;x0, T1 &amp;x1){OT(x0), OT(x1);}\r\ntemplate&lt;class T0, class T1, class T2&gt; inline void OT(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2){OT(x0), OT(x1), OT(x2);}\r\ntemplate&lt;class T0, class T1, class T2, class T3&gt; inline void OT(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2, T3 &amp;x3){OT(x0), OT(x1), OT(x2), OT(x3);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4&gt; inline void OT(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2, T3 &amp;x3, T4 &amp;x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5&gt; inline void OT(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2, T3 &amp;x3, T4 &amp;x4, T5 &amp;x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5, class T6&gt; inline void OT(T0 &amp;x0, T1 &amp;x1, T2 &amp;x2, T3 &amp;x3, T4 &amp;x4, T5 &amp;x5, T6 &amp;x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\r\n\r\ntemplate&lt;class T&gt; inline void RST(T &amp;A){memset(A, 0, sizeof(A));}\r\ntemplate&lt;class T0, class T1&gt; inline void RST(T0 &amp;A0, T1 &amp;A1){RST(A0), RST(A1);}\r\ntemplate&lt;class T0, class T1, class T2&gt; inline void RST(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2){RST(A0), RST(A1), RST(A2);}\r\ntemplate&lt;class T0, class T1, class T2, class T3&gt; inline void RST(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3){RST(A0), RST(A1), RST(A2), RST(A3);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4&gt; inline void RST(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5&gt; inline void RST(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4, T5 &amp;A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5, class T6&gt; inline void RST(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4, T5 &amp;A5, T6 &amp;A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\r\ntemplate&lt;class T&gt; inline void CLR(T &amp;A){A.clear();}\r\ntemplate&lt;class T0, class T1&gt; inline void CLR(T0 &amp;A0, T1 &amp;A1){CLR(A0), CLR(A1);}\r\ntemplate&lt;class T0, class T1, class T2&gt; inline void CLR(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2){CLR(A0), CLR(A1), CLR(A2);}\r\ntemplate&lt;class T0, class T1, class T2, class T3&gt; inline void CLR(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4&gt; inline void CLR(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5&gt; inline void CLR(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4, T5 &amp;A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5, class T6&gt; inline void CLR(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4, T5 &amp;A5, T6 &amp;A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\r\ntemplate&lt;class T&gt; inline void CLR(T &amp;A, int n){REP(i, n) CLR(A&#x5B;i]);}\r\ntemplate&lt;class T&gt; inline void FLC(T &amp;A, int x){memset(A, x, sizeof(A));}\r\ntemplate&lt;class T0, class T1&gt; inline void FLC(T0 &amp;A0, T1 &amp;A1, int x){FLC(A0, x), FLC(A1, x);}\r\ntemplate&lt;class T0, class T1, class T2&gt; inline void FLC(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2){FLC(A0), FLC(A1), FLC(A2);}\r\ntemplate&lt;class T0, class T1, class T2, class T3&gt; inline void FLC(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4&gt; inline void FLC(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5&gt; inline void FLC(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4, T5 &amp;A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}\r\ntemplate&lt;class T0, class T1, class T2, class T3, class T4, class T5, class T6&gt; inline void FLC(T0 &amp;A0, T1 &amp;A1, T2 &amp;A2, T3 &amp;A3, T4 &amp;A4, T5 &amp;A5, T6 &amp;A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}\r\n\r\ntemplate&lt;class T&gt; inline void SRT(T &amp;A){sort(ALL(A));}\r\ntemplate&lt;class T, class C&gt; inline void SRT(T &amp;A, C B){sort(ALL(A), B);}\r\n\r\n\r\n\/** Add - On **\/\r\n\r\nconst int MOD = 1000000007;\r\nconst int INF = 0x7fffffff;\r\nconst DB PI = acos(-1.0);\r\nconst DB EPS = 1e-6;\r\nconst DB OO = 1e15;\r\n\r\n\/\/ &lt;&lt;= ` 0. Daily Use .,\r\n\r\ntemplate&lt;class T&gt; inline void checkMin(T &amp;a,const T b){if (b&lt;a) a=b;}\r\ntemplate&lt;class T&gt; inline void checkMax(T &amp;a,const T b){if (b&gt;a) a=b;}\r\ntemplate &lt;class T, class C&gt; inline void checkMin(T&amp; a, const T b, C c){if (c(b,a)) a = b;}\r\ntemplate &lt;class T, class C&gt; inline void checkMax(T&amp; a, const T b, C c){if (c(a,b)) a = b;}\r\ntemplate&lt;class T&gt; inline T min(T a, T b, T c){return min(min(a, b), c);}\r\ntemplate&lt;class T&gt; inline T max(T a, T b, T c){return max(max(a, b), c);}\r\ntemplate&lt;class T&gt; inline T sqr(T a){return a*a;}\r\ntemplate&lt;class T&gt; inline T cub(T a){return a*a*a;}\r\nint Ceil(int x, int y){return (x - 1) \/ y + 1;}\r\n\r\n\/\/ &lt;&lt;= ` 1. Bitwise Operation .,\r\n\r\ninline bool _1(int x, int i){return x &amp; 1&lt;&lt;i;}\r\ninline int _1(int i){return 1&lt;&lt;i;}\r\ninline int _U(int i){return _1(i) - 1;};\r\n\r\ninline int count_bits(int x){\r\n    x = (x &amp; 0x55555555) + ((x &amp; 0xaaaaaaaa) &gt;&gt; 1);\r\n    x = (x &amp; 0x33333333) + ((x &amp; 0xcccccccc) &gt;&gt; 2);\r\n    x = (x &amp; 0x0f0f0f0f) + ((x &amp; 0xf0f0f0f0) &gt;&gt; 4);\r\n    x = (x &amp; 0x00ff00ff) + ((x &amp; 0xff00ff00) &gt;&gt; 8);\r\n    x = (x &amp; 0x0000ffff) + ((x &amp; 0xffff0000) &gt;&gt; 16);\r\n    return x;\r\n}\r\n\r\ntemplate&lt;class T&gt; inline T low_bit(T x) {\r\n    return x &amp; -x;\r\n}\r\n\r\ntemplate&lt;class T&gt; inline T high_bit(T x) {\r\n    T p = low_bit(x);\r\n    while (p != x) x -= p, p = low_bit(x);\r\n    return p;\r\n}\r\n\r\n\/\/ &lt;&lt;= ` 2. Modular Arithmetic Basic .,\r\n\r\ninline void INC(int &amp;a, int b){a += b; if (a &gt;= MOD) a -= MOD;}\r\ninline int sum(int a, int b){a += b; if (a &gt;= MOD) a -= MOD; return a;}\r\ninline void DEC(int &amp;a, int b){a -= b; if (a &lt; 0) a += MOD;}\r\ninline int dff(int a, int b){a -= b; if (a &lt; 0) a  += MOD; return a;}\r\ninline void MUL(int &amp;a, int b){a = (LL)a * b % MOD;}\r\ninline int pdt(int a, int b){return (LL)a * b % MOD;}\r\n\r\n\r\n\/\/ &lt;&lt;= ' 0. I\/O Accelerator interface .,\r\n\r\ntemplate&lt;class T&gt; inline void RD(T &amp;x){\r\n    \/\/cin &gt;&gt; x;\r\n    scanf(&quot;%d&quot;, &amp;x);\r\n    \/\/char c; for (c = getchar(); c &lt; '0'; c = getchar()); x = c - '0'; for (c = getchar(); c &gt;= '0'; c = getchar()) x = x * 10 + c - '0';\r\n    \/\/char c; c = getchar(); x = c - '0'; for (c = getchar(); c &gt;= '0'; c = getchar()) x = x * 10 + c - '0';\r\n    \r\n}\r\n\r\ntemplate&lt;class T&gt; inline void OT(const T &amp;x){\r\n    printf(&quot;%.3lf\\n&quot;, x);\r\n}\r\n\r\n\r\n#define For_each(it, A) for (SII::iterator it = A.begin(); it != A.end(); ++it)\r\n\r\n\/* .................................................................................................................................. *\/\r\n\r\ninline int sgn(DB x){\r\n    return x &lt; -EPS ? -1 : x &gt; EPS;\r\n}\r\n\r\nconst int N = 1009;\r\n\r\nint x&#x5B;N], y&#x5B;N], r&#x5B;N], o&#x5B;N]; \/\/ Circle\r\n\r\n#define m ((l + r) \/ 2)\r\n#define l(a) x&#x5B;a] - r&#x5B;a]\r\n#define r(a) x&#x5B;a] + r&#x5B;a]\r\n\r\ninline bool c1(int a, int b){return r&#x5B;a] &lt; r&#x5B;b];} \/\/Sort by Radius\r\ninline bool c2(int a, int b){return l(a) &lt; l(b);} \/\/Sort by left point.\r\ninline bool Cover(int a, int b){return sqr(r&#x5B;a] - r&#x5B;b]) &gt;= sqr(x&#x5B;a] - x&#x5B;b]) + sqr(y&#x5B;a] - y&#x5B;b]);}\r\n\r\nint n;\r\n\r\nvector&lt;pair&lt;DB, DB&gt; &gt; I; \/\/ Interval\r\nmap&lt;DB, DB&gt; _f;\r\n\r\n#define lbd I&#x5B;i].first\r\n#define rbd I&#x5B;i].second\r\n\r\ninline DB f(DB xx){\r\n    \r\n    DB &amp;res = _f&#x5B;xx];\r\n    \r\n    if (res == 0) {\r\n        CLR(I); REP(i, n){\r\n            DB d = fabs(xx - x&#x5B;i]);\r\n            if (d &lt; r&#x5B;i]) d = sqrt(sqr(r&#x5B;i]) - sqr(d)), I.PB(MP(y&#x5B;i] - d, y&#x5B;i] + d));\r\n        }\r\n    \r\n        SRT(I);\r\n    \r\n        DB ll = -OO, rr = -OO; REP(i, SZ(I)){\r\n            if(rr &lt; lbd) res += rr - ll, ll = lbd, rr = rbd;\r\n            else checkMax(rr, rbd);\r\n        }\r\n    \r\n        res += rr - ll;\r\n    }\r\n    \r\n    return res;\r\n}\r\n\r\ninline DB s(DB l, DB r){\r\n    return (f(l) + 4 * f(m) + f(r)) * (r - l);\r\n}\r\n\r\ninline DB _S(DB l, DB r){\r\n    DB ss = s(l, r), sl = s(l, m), sr = s(m, r);\r\n    if (fabs(ss - sl - sr) &lt; EPS) return sl + sr;\r\n    else return _S(l, m) + _S(m, r);\r\n}\r\n\r\ninline DB S(DB l, DB r){\r\n    CLR(_f); return _S(l, r);\r\n}\r\n\r\nint main(){\r\n    \r\n    \/\/freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n    \r\n    RD(n); for (int i=0;i&lt;n;r&#x5B;i]?++i:--n) RD(x&#x5B;i], y&#x5B;i], r&#x5B;i]);\r\n    \r\n    \/\/ Delete some useless circle .. .\r\n    \r\n    REP(i, n) o&#x5B;i] = i; sort(o, o + n, c1);\r\n    \r\n    REP(i, n) FOR(j, i+1, n) if (Cover(o&#x5B;j], o&#x5B;i])){o&#x5B;i] = -1; break;}\r\n    \r\n    int _n = n; n = 0; REP(i, _n) if (o&#x5B;i] != -1) o&#x5B;n++] = o&#x5B;i];\r\n    \r\n    sort(o, o + n, c2);\r\n    \r\n    int _x&#x5B;N], _y&#x5B;N], _r&#x5B;N];\r\n    \r\n    REP(i, n) _x&#x5B;i] = x&#x5B;o&#x5B;i]], _y&#x5B;i] = y&#x5B;o&#x5B;i]], _r&#x5B;i] = r&#x5B;o&#x5B;i]];\r\n    \r\n    CPY(x, _x), CPY(y, _y), CPY(r, _r);\r\n    \r\n    \/\/ Calculate Area by the Simpson's Rule .. .\r\n    \r\n    DB Area = 0, ll = -OO, rr = -OO;\r\n    \r\n    REP(i, n){\r\n        if(rr &lt; l(i)) Area += S(ll, rr), ll = l(i), rr = r(i);\r\n        else checkMax(rr, DB(r(i)));\r\n    }\r\n    \r\n    Area += S(ll, rr), Area \/= 6;\r\n    \r\n    OT(Area);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/zh.wikipedia.org\/wiki\/%E9%A4%98%E5%BC%A6%E5%AE%9A%E7%90%86 http:\/\/www.cnblogs.com\/ch3656468\/archive\/2011\/03\/02\/1969303.html http:\/\/hi.baidu.com\/billdu\/blog\/item\/2b162f7bb799affa2e73b331.html http:\/\/user.qzone.qq.com\/122155302\/blog\/1311607940 http:\/\/zh.wikipedia.org\/wiki\/%E9%A4%98%E5%BC%A6%E5%AE%9A%E7%90%86<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[26,25,7],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-26","tag-25","tag-7"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-q","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":28,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/26\/revisions\/28"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}