锘??xml version="1.0" encoding="utf-8" standalone="yes"?>无码任你躁久久久久久老妇App,午夜天堂av天堂久久久,亚洲中文久久精品无码ww16http://www.shnenglu.com/schindlerlee/zh-cnThu, 08 May 2025 16:02:44 GMTThu, 08 May 2025 16:02:44 GMT60鑵捐vs360http://www.shnenglu.com/schindlerlee/archive/2010/11/04/132440.htmlschindlerleeschindlerleeThu, 04 Nov 2010 06:58:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/11/04/132440.htmlhttp://www.shnenglu.com/schindlerlee/comments/132440.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/11/04/132440.html#Feedback0http://www.shnenglu.com/schindlerlee/comments/commentRss/132440.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/132440.htmlThe criminals in this town used to believe in things. Honor. Respect. Look at you! What do you believe in? What do you believe in?
--from <<Dark Knight>>


]]>
杞澆涓浣嶇綉鍙嬪湪imdb琚涔嬪悗鐨勪竴鐐硅瘎璁?/title><link>http://www.shnenglu.com/schindlerlee/archive/2010/10/26/131322.html</link><dc:creator>schindlerlee</dc:creator><author>schindlerlee</author><pubDate>Tue, 26 Oct 2010 04:41:00 GMT</pubDate><guid>http://www.shnenglu.com/schindlerlee/archive/2010/10/26/131322.html</guid><wfw:comment>http://www.shnenglu.com/schindlerlee/comments/131322.html</wfw:comment><comments>http://www.shnenglu.com/schindlerlee/archive/2010/10/26/131322.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/schindlerlee/comments/commentRss/131322.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/schindlerlee/services/trackbacks/131322.html</trackback:ping><description><![CDATA[ <br />椹厠鎬濋兘璇翠簡鈥滃弽瀵瑰懼悜鎬х殑娉曞緥錛屽嵆娌℃湁瑙勫畾瀹㈣鏍囧噯鐨勬硶寰嬶紝涔冩槸鎭愭栦富涔夌殑娉曞緥鈥濄傚彧鏄浜庡娉曞啓鐨勫拰瀹為檯鐨勬劅鍙楀畬鍏ㄧ浉鍙嶇殑鏃跺欎綘鎬繪槸浼氭劅瑙夊緢鎭肩伀鐨勶紝鐗瑰埆瀹硶絎竴鏉″氨鍐欑潃鍧氭寔椹厠鎬濅富涔夛紝閭d箞娉曟不榪欎釜璇存硶灝辨樉寰楀緢婊戠ń浜嗐?br /><br />鍘熸枃錛歨ttp://jackyhds.wordpress.com/2010/01/21/imdb%E8%A2%AB%E5%A2%99/<br /><img src ="http://www.shnenglu.com/schindlerlee/aggbug/131322.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/schindlerlee/" target="_blank">schindlerlee</a> 2010-10-26 12:41 <a href="http://www.shnenglu.com/schindlerlee/archive/2010/10/26/131322.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>zju2589 涓嶉噸鍚堢殑n涓渾褰㈡垚鐨勫尯鍩?/title><link>http://www.shnenglu.com/schindlerlee/archive/2010/07/08/119784.html</link><dc:creator>schindlerlee</dc:creator><author>schindlerlee</author><pubDate>Thu, 08 Jul 2010 14:06:00 GMT</pubDate><guid>http://www.shnenglu.com/schindlerlee/archive/2010/07/08/119784.html</guid><wfw:comment>http://www.shnenglu.com/schindlerlee/comments/119784.html</wfw:comment><comments>http://www.shnenglu.com/schindlerlee/archive/2010/07/08/119784.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/schindlerlee/comments/commentRss/119784.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/schindlerlee/services/trackbacks/119784.html</trackback:ping><description><![CDATA[ <img src="http://www.shnenglu.com/images/cppblog_com/schindlerlee/14203/o_%E5%9C%86%E5%88%86%E5%89%B2%E5%8C%BA%E5%9F%9F.png" /> <br /> <div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 128, 128);">聽聽1</span>聽<span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">聽<br /></span><span style="color: rgb(0, 128, 128);">聽聽2</span>聽<span style="color: rgb(0, 128, 0);">聽*聽SOUR:zju2589<br /></span><span style="color: rgb(0, 128, 128);">聽聽3</span>聽<span style="color: rgb(0, 128, 0);">聽*聽ALGO:computational聽geomtry聽璁$畻騫抽潰涓婁笉閲嶅悎鐨刵涓渾褰㈡垚鐨勫尯鍩?br /></span><span style="color: rgb(0, 128, 128);">聽聽4</span>聽<span style="color: rgb(0, 128, 0);">聽*聽鍩烘湰鐨勬柟娉曪紝濡傚浘鎵紺猴紝灝嗘墍鏈夊渾涔嬮棿鐨勪氦鐐逛綔涓虹偣錛屽皢鍦ㄥ悓涓涓渾涓婄殑鎵鏈変氦鐐逛箣闂寸殑寮т綔<br /></span><span style="color: rgb(0, 128, 128);">聽聽5</span>聽<span style="color: rgb(0, 128, 0);">聽*聽涓鴻竟寤虹珛涓寮犳湁鍚戝浘錛屼箣鍚庡彲浠ュ埄鐢ㄥ鉤闈㈠浘鐨勬鎷夊畾鐞?br /></span><span style="color: rgb(0, 128, 128);">聽聽6</span>聽<span style="color: rgb(0, 128, 0);">聽*聽聽聽聽聽聽聽聽聽聽聽V聽-聽E聽+聽F聽=聽2<br /></span><span style="color: rgb(0, 128, 128);">聽聽7</span>聽<span style="color: rgb(0, 128, 0);">聽*聽鐢變簬V宸茬煡錛孍宸茬煡錛孎灝卞彲浠ユ眰鍑烘潵浜嗐?br /></span><span style="color: rgb(0, 128, 128);">聽聽8</span>聽<span style="color: rgb(0, 128, 0);">聽*聽鐢變簬嬈ф媺瀹氱悊鏄涓寮犳棤鍚戣繛閫氬浘鎴愮珛鐨勶紝濡傛灉鍥炬湁澶氫釜榪為氬潡鐨勬椂鍊欓渶瑕佸嬈ф媺瀹氱悊鍋氫竴浜?br /></span><span style="color: rgb(0, 128, 128);">聽聽9</span>聽<span style="color: rgb(0, 128, 0);">聽*聽淇敼銆傜敱浜庡涓湁鍚戝浘鐨勯潰鍏變韓鏈澶栬竟鐨勯潰錛屾墍浠ヨ鑱旈氬潡鐨勪釜鏁頒負n<br /></span><span style="color: rgb(0, 128, 128);">聽10</span>聽<span style="color: rgb(0, 128, 0);">聽*聽V聽-聽E聽+聽F聽=聽2聽*聽n聽,聽浣嗘槸闇瑕佸噺鍘籲涓仈閫氬潡鍏變韓鐨勬渶澶у鉤闈?br /></span><span style="color: rgb(0, 128, 128);">聽11</span>聽<span style="color: rgb(0, 128, 0);">聽*聽鎵浠ヂ燜聽=聽n聽+聽1聽+聽E聽-聽V;<br /></span><span style="color: rgb(0, 128, 128);">聽12</span>聽<span style="color: rgb(0, 128, 0);">聽*聽DATE:聽2010騫綽?7鏈埪?8鏃ヂ犳槦鏈熷洓聽14:49:41聽CST<br /></span><span style="color: rgb(0, 128, 128);">聽13</span>聽<span style="color: rgb(0, 128, 0);">聽*聽COMM:5<br /></span><span style="color: rgb(0, 128, 128);">聽14</span>聽<span style="color: rgb(0, 128, 0);">聽*聽</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽15</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽N聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">64</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽16</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽eps聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽1e</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽17</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽n,聽vis[N],聽g[N][N];<br /></span><span style="color: rgb(0, 128, 128);">聽18</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽r[N];<br /></span><span style="color: rgb(0, 128, 128);">聽19</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">struct</span><span style="color: rgb(0, 0, 0);">聽point_t聽{<br /></span><span style="color: rgb(0, 128, 128);">聽20</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽x,聽y;<br /></span><span style="color: rgb(0, 128, 128);">聽21</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽point_t(){}<br /></span><span style="color: rgb(0, 128, 128);">聽22</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽point_t(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽a,聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽b){x聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽a,聽y聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽b;}聽<br /></span><span style="color: rgb(0, 128, 128);">聽23</span>聽<span style="color: rgb(0, 0, 0);">}c[N];<br /></span><span style="color: rgb(0, 128, 128);">聽24</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽25</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽dcmp(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽x)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽(x聽</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽eps)聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽(x聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">eps);}聽<br /></span><span style="color: rgb(0, 128, 128);">聽26</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">bool</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">operator</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽(point_t聽a,point_t聽b)聽<br /></span><span style="color: rgb(0, 128, 128);">聽27</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">聽28</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(dcmp(a.x聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽b.x))聽{<br /></span><span style="color: rgb(0, 128, 128);">聽29</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽a.x聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽b.x;<br /></span><span style="color: rgb(0, 128, 128);">聽30</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽31</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽dcmp(a.y聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽b.y)聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽32</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">聽33</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽34</span>聽<span style="color: rgb(0, 0, 0);">point_t聽</span><span style="color: rgb(0, 0, 255);">operator</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽(point_t聽a,聽point_t聽b)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽point_t(a.x</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">b.x,聽a.y</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">b.y);}<br /></span><span style="color: rgb(0, 128, 128);">聽35</span>聽<span style="color: rgb(0, 0, 0);">point_t聽</span><span style="color: rgb(0, 0, 255);">operator</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽(point_t聽a,聽point_t聽b)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽point_t(a.x</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">b.x,聽a.y</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">b.y);}<br /></span><span style="color: rgb(0, 128, 128);">聽36</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽dist(point_t聽a,聽point_t聽b)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽hypot(a.x</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">b.x,聽a.y</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">b.y);}<br /></span><span style="color: rgb(0, 128, 128);">聽37</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽sqr(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽x)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽x;}<br /></span><span style="color: rgb(0, 128, 128);">聽38</span>聽<span style="color: rgb(0, 0, 0);">point_t聽normal(point_t聽a)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽point_t(a.x聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽hypot(a.x,聽a.y),聽a.y聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽hypot(a.x,聽a.y));}<br /></span><span style="color: rgb(0, 128, 128);">聽39</span>聽<span style="color: rgb(0, 0, 0);">point_t聽scale(point_t聽a,聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽fac)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽point_t(a.x聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽fac,聽a.y聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽fac);}<br /></span><span style="color: rgb(0, 128, 128);">聽40</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">bool</span><span style="color: rgb(0, 0, 0);">聽intersect(point_t聽c1,聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽r1,聽point_t聽c2,聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽r2,聽point_t聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">a,聽point_t聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">b)<br /></span><span style="color: rgb(0, 128, 128);">聽41</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">聽42</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽d聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽dist(c1,聽c2);<br /></span><span style="color: rgb(0, 128, 128);">聽43</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(d聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽fabs(r1聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽r2)聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽eps聽</span><span style="color: rgb(0, 0, 0);">||</span><span style="color: rgb(0, 0, 0);">聽d聽</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽r1聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽r2聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽eps)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽44</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽45</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽46</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽len聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽(sqr(r1)聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽sqr(r2)聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽sqr(d))聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">2.0</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽d;<br /></span><span style="color: rgb(0, 128, 128);">聽47</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽h聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽sqrt(sqr(r1)聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽sqr(len));<br /></span><span style="color: rgb(0, 128, 128);">聽48</span>聽<span style="color: rgb(0, 0, 0);">聽聽point_t聽t聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽normal(c2聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽c1);<br /></span><span style="color: rgb(0, 128, 128);">聽49</span>聽<span style="color: rgb(0, 0, 0);">聽聽point_t聽p聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽c1聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽scale(t,聽len);<br /></span><span style="color: rgb(0, 128, 128);">聽50</span>聽<span style="color: rgb(0, 0, 0);">聽聽point_t聽v聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽scale(point_t(</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">t.y,聽t.x),聽h);<br /></span><span style="color: rgb(0, 128, 128);">聽51</span>聽<span style="color: rgb(0, 0, 0);">聽聽a聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽p聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽v,聽b聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽p聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">v;<br /></span><span style="color: rgb(0, 128, 128);">聽52</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽53</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">聽54</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽55</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽init()<br /></span><span style="color: rgb(0, 128, 128);">聽56</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">聽57</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i;<br /></span><span style="color: rgb(0, 128, 128);">聽58</span>聽<span style="color: rgb(0, 0, 0);">聽聽memset(g,聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 255);">sizeof</span><span style="color: rgb(0, 0, 0);">(g));<br /></span><span style="color: rgb(0, 128, 128);">聽59</span>聽<span style="color: rgb(0, 0, 0);">聽聽memset(vis,聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 255);">sizeof</span><span style="color: rgb(0, 0, 0);">(vis));<br /></span><span style="color: rgb(0, 128, 128);">聽60</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽61</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽g[i][i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽62</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽63</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">聽64</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽65</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽main()<br /></span><span style="color: rgb(0, 128, 128);">聽66</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">聽67</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽testcase,聽i,聽j,聽k;<br /></span><span style="color: rgb(0, 128, 128);">聽68</span>聽<span style="color: rgb(0, 0, 0);">聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">testcase);<br /></span><span style="color: rgb(0, 128, 128);">聽69</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">聽(testcase</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽70</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">n);<br /></span><span style="color: rgb(0, 128, 128);">聽71</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">point_t</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽allpoint,聽p[</span><span style="color: rgb(0, 0, 0);">64</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">聽72</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽73</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%lf聽%lf聽%lf</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">c[i].x,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">c[i].y,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">r[i]);<br /></span><span style="color: rgb(0, 128, 128);">聽74</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽75</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽init();<br /></span><span style="color: rgb(0, 128, 128);">聽76</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽77</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽i聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;j聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽78</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽point_t聽a,聽b;<br /></span><span style="color: rgb(0, 128, 128);">聽79</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(intersect(c[i],聽r[i],聽c[j],聽r[j],聽a,聽b))聽{<br /></span><span style="color: rgb(0, 128, 128);">聽80</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽allpoint.insert(a),聽allpoint.insert(b);<br /></span><span style="color: rgb(0, 128, 128);">聽81</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽p[i].insert(a),聽p[i].insert(b);<br /></span><span style="color: rgb(0, 128, 128);">聽82</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽p[j].insert(a),聽p[j].insert(b);<br /></span><span style="color: rgb(0, 128, 128);">聽83</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽g[i][j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽g[j][i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽84</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽85</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽86</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽87</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(k聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;k聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;k</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽88</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽89</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;j聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽90</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽g[i][j]聽</span><span style="color: rgb(0, 0, 0);">|=</span><span style="color: rgb(0, 0, 0);">聽g[i][k]聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">聽g[k][j];<br /></span><span style="color: rgb(0, 128, 128);">聽91</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽92</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽93</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽94</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽f聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽95</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽96</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽f聽</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">聽p[i].size();<br /></span><span style="color: rgb(0, 128, 128);">聽97</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">vis[i])聽{<br /></span><span style="color: rgb(0, 128, 128);">聽98</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽f聽</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽99</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;j聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">100</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽vis[j]聽</span><span style="color: rgb(0, 0, 0);">|=</span><span style="color: rgb(0, 0, 0);">聽g[i][j];<br /></span><span style="color: rgb(0, 128, 128);">101</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">102</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">103</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">104</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽f聽</span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);">聽allpoint.size();<br /></span><span style="color: rgb(0, 128, 128);">105</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽f);<br /></span><span style="color: rgb(0, 128, 128);">106</span>聽<span style="color: rgb(0, 0, 0);">聽聽}聽<br /></span><span style="color: rgb(0, 128, 128);">107</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">108</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">109</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">110</span>聽<span style="color: rgb(0, 0, 0);"></span></div> <br /> <img src ="http://www.shnenglu.com/schindlerlee/aggbug/119784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/schindlerlee/" target="_blank">schindlerlee</a> 2010-07-08 22:06 <a href="http://www.shnenglu.com/schindlerlee/archive/2010/07/08/119784.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>pku3334 浜屽垎+姹傚杈瑰艦闈㈢Нhttp://www.shnenglu.com/schindlerlee/archive/2010/07/08/119778.htmlschindlerleeschindlerleeThu, 08 Jul 2010 13:34:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/07/08/119778.htmlhttp://www.shnenglu.com/schindlerlee/comments/119778.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/07/08/119778.html#Feedback0http://www.shnenglu.com/schindlerlee/comments/commentRss/119778.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/119778.html 聽1/*
聽2聽*聽SOUR:pku3334
聽3聽*聽ALGO:浜屽垎楂樺害錛屾眰姘村鉤綰垮拰澶氳竟褰㈢殑浜ょ偣錛屾眰鍑哄杈瑰艦闈㈢Н
聽4聽*聽DATE:聽2010騫綽?7鏈埪?7鏃ヂ犳槦鏈熶笁聽22:29:14聽CST
聽5聽*聽*/
聽6constint聽N聽=1024;
聽7struct聽point_t聽{
聽8聽聽聽聽double聽x,聽y;
聽9聽聽聽聽point_t聽(){}
10聽聽聽聽point_t聽(double聽a,聽double聽b){x聽=聽a,聽y聽=聽b;}
11}P[N],聽Q[N];
12int聽m,聽n,聽cp,聽cq;
13double聽area;
14
15point_t聽operator+聽(point_t聽a,聽point_t聽b)聽{聽return聽point_t(a.x聽+聽b.x,聽a.y聽+聽b.y);}
16point_t聽operator-聽(point_t聽a,聽point_t聽b)聽{聽return聽point_t(a.x聽-聽b.x,聽a.y聽-聽b.y);}
17double聽SQR(double聽x聽){聽return聽x聽*聽x;}
18double聽dist(point_t聽a)聽{聽return聽sqrt(SQR(a.x)聽+聽SQR(a.y));}
19double聽dist(point_t聽a,聽point_t聽b)聽{聽return聽dist(a-b);}
20double聽cross_mul(point_t聽a,聽point_t聽b)聽{聽return聽a.x聽*聽b.y聽-聽a.y聽*聽b.x;}
21constdouble聽eps聽=聽1e-10;
22
23double聽calcu(point_t聽p[],聽int聽n,聽int聽cusp,聽double聽h)
24{
25聽聽double聽ans聽=0;
26聽聽int聽i,聽j,聽k,聽beg聽=0,聽end聽=聽n聽-1;
27聽聽if聽(h聽<=聽p[cusp].y)聽{
28聽聽聽聽聽聽return0;
29聽聽}
30聽聽for聽(i聽=0;i聽<聽cusp;i聽++)聽{
31聽聽聽聽聽聽if聽(p[i].y聽>=聽h聽&&聽h聽>=聽p[i+1].y)聽{
32聽聽聽聽聽聽聽聽聽聽beg聽=聽i;break;
33聽聽聽聽聽聽}
34聽聽}
35聽聽for聽(i聽=聽n聽-2;i聽>=聽cusp;i--)聽{
36聽聽聽聽聽聽if聽(p[i].y聽<=聽h聽&&聽h聽<=聽p[i+1].y)聽{
37聽聽聽聽聽聽聽聽聽聽end聽=聽i;break;
38聽聽聽聽聽聽}
39聽聽}
40
41聽聽point_t聽a聽=聽point_t(p[beg].x聽+聽(h聽-聽p[beg].y)聽*聽(p[beg+1].x聽-聽p[beg].x)
42聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽/聽(p[beg+1].y聽-聽p[beg].y)聽,聽h);
43聽聽point_t聽b聽=聽point_t(p[end].x聽+聽(h聽-聽p[end].y)聽*聽(p[end+1].x聽-聽p[end].x)
44聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽/聽(p[end+1].y聽-聽p[end].y)聽,聽h);
45聽聽ans聽+=聽cross_mul(a,聽p[beg+1])聽+聽cross_mul(p[end],聽b)聽+聽cross_mul(b,聽a);
46聽聽for聽(i聽=聽beg聽+1;i聽<=聽end聽-1;i++)聽{
47聽聽聽聽聽聽ans聽+=聽cross_mul(p[i],聽p[i+1]);
48聽聽}
49聽聽return聽fabs(ans聽/2.0);
50}
51
52int聽main()
53{
54聽聽int聽testcase,聽i;
55聽聽scanf("%d",聽&testcase);
56聽聽while聽(testcase--)聽{
57聽聽聽聽聽聽scanf("%lf",聽&area);
58聽聽聽聽聽聽scanf("%d",聽&m);聽for聽(i聽=0;i聽<聽m;i++)聽{聽scanf("%lf聽%lf",聽&P[i].x,聽&P[i].y);聽}
59聽聽聽聽聽聽scanf("%d",聽&n);聽for聽(i聽=0;i聽<聽n;i++)聽{聽scanf("%lf聽%lf",聽&Q[i].x,聽&Q[i].y);聽}
60聽聽聽聽聽聽for聽(i聽=1;i聽<聽m-1;i++)聽{
61聽聽聽聽聽聽聽聽聽聽if聽(P[i-1].y聽>=聽P[i].y聽&&聽P[i].y聽<=聽P[i+1].y)聽{
62聽聽聽聽聽聽聽聽聽聽聽聽聽聽cp聽=聽i;
63聽聽聽聽聽聽聽聽聽聽}
64聽聽聽聽聽聽}
65聽聽聽聽聽聽for聽(i聽=1;i聽<聽n-1;i++)聽{
66聽聽聽聽聽聽聽聽聽聽if聽(Q[i-1].y聽>=聽Q[i].y聽&&聽Q[i].y聽<=聽Q[i+1].y)聽{
67聽聽聽聽聽聽聽聽聽聽聽聽聽聽cq聽=聽i;
68聽聽聽聽聽聽聽聽聽聽}
69聽聽聽聽聽聽}
70聽聽聽聽聽聽double聽L聽=聽min(P[cp].y聽,聽Q[cq].y),
71聽聽聽聽聽聽聽聽聽聽聽聽聽R聽=聽min(min(P[0].y,聽P[m聽-1].y)聽,聽min(Q[0].y,聽Q[n聽-1].y))聽;
72聽聽聽聽聽聽while聽(L聽+聽eps聽<聽R)聽{
73聽聽聽聽聽聽聽聽聽聽double聽mid聽=聽(L聽+聽R)聽/2.0;
74聽聽聽聽聽聽聽聽聽聽double聽A聽=聽calcu(P,聽m,聽cp,聽mid)聽+聽calcu(Q,聽n,聽cq,聽mid);
75聽聽聽聽聽聽聽聽聽聽//printf("h聽=聽%.3f,聽A聽=聽%.3f\n",聽mid,聽A);
76聽聽聽聽聽聽聽聽聽聽if聽(A聽<=聽area)聽{
77聽聽聽聽聽聽聽聽聽聽聽聽聽聽L聽=聽mid;
78聽聽聽聽聽聽聽聽聽聽}else聽{
79聽聽聽聽聽聽聽聽聽聽聽聽聽聽R聽=聽mid;
80聽聽聽聽聽聽聽聽聽聽}
81聽聽聽聽聽聽}
82聽聽聽聽聽聽printf("%.3f\n",聽L);
83聽聽}
84聽聽return0;
85}
86
87
88


]]>
hdu3264 浜屽垎+姹備袱鍦嗕氦鐨勯潰縐?/title><link>http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119518.html</link><dc:creator>schindlerlee</dc:creator><author>schindlerlee</author><pubDate>Tue, 06 Jul 2010 17:48:00 GMT</pubDate><guid>http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119518.html</guid><wfw:comment>http://www.shnenglu.com/schindlerlee/comments/119518.html</wfw:comment><comments>http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119518.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/schindlerlee/comments/commentRss/119518.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/schindlerlee/services/trackbacks/119518.html</trackback:ping><description><![CDATA[ <br /> 浜屽垎鍗婂緞錛屽皢姹傝В闂鍙樻垚鍒ゆ柇鎬ч棶棰樸?br /> 鍒╃敤姹傚渾浜ら潰縐殑鏂規硶鍒ゆ柇鍙鎬с?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_014728" onclick="this.style.display='none'; Code_Closed_Text_014728.style.display='none'; Code_Open_Image_014728.style.display='inline'; Code_Open_Text_014728.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedBlock.gif" width="11" align="top" height="16" /><img id="Code_Open_Image_014728" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_014728.style.display='none'; Code_Closed_Image_014728.style.display='inline'; Code_Closed_Text_014728.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" align="top" height="16" /><span id="Code_Closed_Text_014728" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"></span><span id="Code_Open_Text_014728" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">聽1</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽2</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽N聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">32</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽3</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽eps聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽1e</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">7</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽4</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽5</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">struct</span><span style="color: rgb(0, 0, 0);">聽circle_t聽{<br /></span><span style="color: rgb(0, 128, 128);">聽6</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽r,聽x,聽y;<br /></span><span style="color: rgb(0, 128, 128);">聽7</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽circle_t聽(){}<br /></span><span style="color: rgb(0, 128, 128);">聽8</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽circle_t聽(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽a,聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽b,聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽c){r聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽a,聽x聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽b,聽y聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽c;}<br /></span><span style="color: rgb(0, 128, 128);">聽9</span>聽<span style="color: rgb(0, 0, 0);">}c[N];<br /></span><span style="color: rgb(0, 128, 128);">10</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽n;<br /></span><span style="color: rgb(0, 128, 128);">11</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽ans;<br /></span><span style="color: rgb(0, 128, 128);">12</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽area[N];<br /></span><span style="color: rgb(0, 128, 128);">13</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">14</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽pi聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽acos(</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1.0</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">15</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽SQR(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽x)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽x;}<br /></span><span style="color: rgb(0, 128, 128);">16</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">17</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽intersect(circle_t聽c1,聽circle_t聽c2)<br /></span><span style="color: rgb(0, 128, 128);">18</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">19</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽ans聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">20</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽d聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽sqrt(SQR(c1.x聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽c2.x)聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽SQR(c1.y聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽c2.y));<br /></span><span style="color: rgb(0, 128, 128);">21</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(c1.r聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽c2.r)聽{<br /></span><span style="color: rgb(0, 128, 128);">22</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽swap(c1,聽c2);<br /></span><span style="color: rgb(0, 128, 128);">23</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">24</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(d聽</span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);">聽c1.r聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽c2.r)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;聽}<br /></span><span style="color: rgb(0, 128, 128);">25</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(d聽</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">聽c1.r聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽c2.r)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽pi聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽SQR(c2.r);聽}<br /></span><span style="color: rgb(0, 128, 128);">26</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽angle1聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽acos((SQR(c1.r)聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽SQR(d)聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽SQR(c2.r))聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">2.0</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽c1.r聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽d);聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">half</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">27</span>聽<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽angle2聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽acos((SQR(c2.r)聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽SQR(d)聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽SQR(c1.r))聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">2.0</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽c2.r聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽d);<br /></span><span style="color: rgb(0, 128, 128);">28</span>聽<span style="color: rgb(0, 0, 0);">聽聽ans聽</span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);">聽d聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽c1.r聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽sin(angle1);<br /></span><span style="color: rgb(0, 128, 128);">29</span>聽<span style="color: rgb(0, 0, 0);">聽聽ans聽</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">聽angle1聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽SQR(c1.r)聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽angle2聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽SQR(c2.r);<br /></span><span style="color: rgb(0, 128, 128);">30</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽ans;<br /></span><span style="color: rgb(0, 128, 128);">31</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">32</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">33</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">bool</span><span style="color: rgb(0, 0, 0);">聽judge(circle_t聽umbrella)<br /></span><span style="color: rgb(0, 128, 128);">34</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">35</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,j,k;<br /></span><span style="color: rgb(0, 128, 128);">36</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">37</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(intersect(umbrella,聽c[i])聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽area[i]</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">38</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">39</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">40</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">41</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">42</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">43</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">44</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽calcu(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽idx)<br /></span><span style="color: rgb(0, 128, 128);">45</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">46</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,j,k;<br /></span><span style="color: rgb(0, 128, 128);">47</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽L聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,聽R聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">200000.0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">48</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">聽(L聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽eps聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽R)聽{<br /></span><span style="color: rgb(0, 128, 128);">49</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽mid聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽(L聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽R)聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">2.0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">50</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(judge(circle_t(mid,聽c[idx].x,聽c[idx].y)))聽{<br /></span><span style="color: rgb(0, 128, 128);">51</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽R聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽mid;<br /></span><span style="color: rgb(0, 128, 128);">52</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">聽{<br /></span><span style="color: rgb(0, 128, 128);">53</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽L聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽mid;<br /></span><span style="color: rgb(0, 128, 128);">54</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">55</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">56</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽L;<br /></span><span style="color: rgb(0, 128, 128);">57</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">58</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">59</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽main()<br /></span><span style="color: rgb(0, 128, 128);">60</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">61</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽testcase,聽i;<br /></span><span style="color: rgb(0, 128, 128);">62</span>聽<span style="color: rgb(0, 0, 0);">聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">testcase);<br /></span><span style="color: rgb(0, 128, 128);">63</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">聽(testcase</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">64</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">n);<br /></span><span style="color: rgb(0, 128, 128);">65</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">66</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%lf聽%lf聽%lf</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">c[i].x,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">c[i].y,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">c[i].r);<br /></span><span style="color: rgb(0, 128, 128);">67</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽area[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽pi聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽SQR(c[i].r);<br /></span><span style="color: rgb(0, 128, 128);">68</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">69</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽ans聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">200000.0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">70</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">71</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽ckmin(ans,聽calcu(i));<br /></span><span style="color: rgb(0, 128, 128);">72</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">73</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%.4f\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽ans);<br /></span><span style="color: rgb(0, 128, 128);">74</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">75</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">76</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">77</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">78</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">79</span>聽<span style="color: rgb(0, 0, 0);"></span></span></div><br /><img src ="http://www.shnenglu.com/schindlerlee/aggbug/119518.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/schindlerlee/" target="_blank">schindlerlee</a> 2010-07-07 01:48 <a href="http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119518.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>zoj2107 鏈榪戠偣瀵癸紝鍒嗘不http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119517.htmlschindlerleeschindlerleeTue, 06 Jul 2010 17:44:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/07/07/119517.htmlhttp://www.shnenglu.com/schindlerlee/comments/119517.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/07/07/119517.html#Feedback0http://www.shnenglu.com/schindlerlee/comments/commentRss/119517.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/119517.html緇冪粌鎵嬪彲浠ワ紝涓嶄細灝辯湅綆楁硶瀵艱鍚с傘?br />
聽1constint聽N聽=100010;
聽2
聽3struct聽point_t聽{
聽4聽聽聽聽double聽x,聽y;
聽5}p[N],聽Y[N];
聽6
聽7double聽sqr(double聽x)聽{聽return聽x聽*聽x;}
聽8bool聽cmp1(const聽point_t聽&a,聽const聽point_t聽&b)
聽9{
10聽聽if聽(a.x聽!=聽b.x)聽{
11聽聽聽聽聽聽return聽a.x聽<聽b.x;
12聽聽}
13聽聽return聽a.y聽<聽b.y;
14}
15
16bool聽cmp2(const聽point_t聽&a,const聽point_t聽&b)
17{
18聽聽if聽(a.y聽!=聽b.y)聽{
19聽聽聽聽聽聽return聽a.y聽<聽b.y;
20聽聽}
21聽聽return聽a.x聽<聽b.x;
22}
23
24constdouble聽inf聽=聽1e100;
25double聽dist(point_t聽a,point_t聽b)聽{聽return聽sqrt(sqr(a.x聽-聽b.x)聽+聽sqr(a.y聽-聽b.y));}
26int聽top;
27
28double聽divide(int聽beg,聽int聽end)
29{
30聽聽double聽ans聽=聽inf;
31聽聽int聽i,j;
32聽聽if聽(end聽<聽beg聽+3)聽{
33聽聽聽聽聽聽for聽(i聽=聽beg;i聽<=聽end;i++)聽{
34聽聽聽聽聽聽聽聽聽聽for聽(j聽=聽i聽+1;j聽<=聽end;j++)聽{
35聽聽聽聽聽聽聽聽聽聽聽聽聽聽ckmin(ans,聽dist(p[i],聽p[j]));
36聽聽聽聽聽聽聽聽聽聽}
37聽聽聽聽聽聽}
38聽聽聽聽聽聽return聽ans;
39聽聽}
40聽聽int聽mid聽=聽(beg聽+聽end)聽>>1,聽cnt;
41聽聽ckmin(ans,聽divide(beg,聽mid));
42聽聽ckmin(ans,聽divide(mid聽+1,聽end));
43聽聽for聽(i聽=聽beg,聽top聽=0;i聽<=聽end;i++)聽{
44聽聽聽聽聽聽if聽(fabs(p[i].x聽-聽p[mid].x)聽<聽ans)聽{
45聽聽聽聽聽聽聽聽聽聽Y[top++]聽=聽p[i];
46聽聽聽聽聽聽}
47聽聽}
48聽聽sort(Y,聽Y聽+聽top,聽cmp2);
49聽聽for聽(i聽=0;i聽<聽top;i++)聽{
50聽聽聽聽聽聽for聽(cnt聽=0,j聽=聽i聽+1;j聽<聽top聽&&聽cnt聽<7;cnt++,聽j++)聽{
51聽聽聽聽聽聽聽聽聽聽ckmin(ans,聽dist(Y[i],聽Y[j]));
52聽聽聽聽聽聽}
53聽聽}
54聽聽return聽ans;
55}
56
57int聽n;
58void聽proc()
59{
60聽聽int聽i,j,k;
61聽聽sort(p,聽p聽+聽n,聽cmp1);
62聽聽double聽ans聽=聽divide(0,聽n聽-1);
63聽聽printf("%.2f\n",聽ans/2.0);
64}
65
66int聽main()
67{
68聽聽int聽i,j,k;
69聽聽while聽(scanf("%d",聽&n)聽==1&&聽n)聽{
70聽聽聽聽聽聽for聽(i聽=0;i聽<聽n;i++)聽{
71聽聽聽聽聽聽聽聽聽聽scanf("%lf聽%lf",聽&p[i].x,聽&p[i].y);
72聽聽聽聽聽聽}
73聽聽聽聽聽聽proc();
74聽聽}
75聽聽return0;
76}
77



]]>
pku1819 鍑犱綍+妯℃嫙 涓嶉毦錛屼絾鏄笉瀹規槗鍐欏http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119516.htmlschindlerleeschindlerleeTue, 06 Jul 2010 17:39:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/07/07/119516.htmlhttp://www.shnenglu.com/schindlerlee/comments/119516.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/07/07/119516.html#Feedback0http://www.shnenglu.com/schindlerlee/comments/commentRss/119516.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/119516.html 瑕佹敞鎰忓垽鏂渾鐨勫乏杈逛笉鑳芥壘榪噛杞淬?br /> 綆楁硶涓嶈В閲娿?br />



]]>
codeforces contest 16 problem E 姣旇緝瀹規槗鐨勭姸鎬佸帇緙╁姩鎬佽鍒掋?/title><link>http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119515.html</link><dc:creator>schindlerlee</dc:creator><author>schindlerlee</author><pubDate>Tue, 06 Jul 2010 17:34:00 GMT</pubDate><guid>http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119515.html</guid><wfw:comment>http://www.shnenglu.com/schindlerlee/comments/119515.html</wfw:comment><comments>http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119515.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/schindlerlee/comments/commentRss/119515.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/schindlerlee/services/trackbacks/119515.html</trackback:ping><description><![CDATA[ <br />鐢ㄤ簩榪涘埗琛ㄧず鏄惁宸茬粡琚悆鎺夛紝鏈鍚庤緭鍑烘墍鏈夊彧鍓╀笅涓涓殑鐘舵併?br />瑕佹敞鎰忕殑鏄姸鎬佽漿縐繪椂鍊欑殑姒傜巼瑕侀櫎浠ユ墍鏈夊彲鑳借漿縐繪暟鎵嶆槸姝g‘鐨勬鐜?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_013325" onclick="this.style.display='none'; Code_Closed_Text_013325.style.display='none'; Code_Open_Image_013325.style.display='inline'; Code_Open_Text_013325.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ContractedBlock.gif" width="11" align="top" height="16" /><img id="Code_Open_Image_013325" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_013325.style.display='none'; Code_Closed_Image_013325.style.display='inline'; Code_Closed_Text_013325.style.display='inline';" src="http://www.shnenglu.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" align="top" height="16" /><span id="Code_Closed_Text_013325" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);"></span><span id="Code_Open_Text_013325" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">聽1</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽2</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽N聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">19</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽3</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">#define</span><span style="color: rgb(0, 0, 0);">聽bin(x)聽(1聽<<聽(x))</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽4</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">#define</span><span style="color: rgb(0, 0, 0);">聽L(x)聽((x)聽<<聽1)</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽5</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">#define</span><span style="color: rgb(0, 0, 0);">聽R(x)聽((x)聽>>聽1)</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽6</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">#define</span><span style="color: rgb(0, 0, 0);">聽low(x)聽((x)聽&聽(-x))</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽7</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽g[N][N];<br /></span><span style="color: rgb(0, 128, 128);">聽8</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽prob[bin(N)];<br /></span><span style="color: rgb(0, 128, 128);">聽9</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽n,聽full;<br /></span><span style="color: rgb(0, 128, 128);">10</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽main()<br /></span><span style="color: rgb(0, 128, 128);">11</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">12</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,j,s;<br /></span><span style="color: rgb(0, 128, 128);">13</span>聽<span style="color: rgb(0, 0, 0);">聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">n);<br /></span><span style="color: rgb(0, 128, 128);">14</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">15</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;j聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">16</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%lf</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">g[i][j]);<br /></span><span style="color: rgb(0, 128, 128);">17</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">18</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">19</span>聽<span style="color: rgb(0, 0, 0);">聽聽full聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽bin(n)聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">20</span>聽<span style="color: rgb(0, 0, 0);">聽聽prob[full]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1.0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">21</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(s聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽full;s聽</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;s</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">22</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽bit聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽countbit(s);<br /></span><span style="color: rgb(0, 128, 128);">23</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽bit聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽bit聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽(bit聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">24</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">(s聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">聽bin(i)))聽{聽</span><span style="color: rgb(0, 0, 255);">continue</span><span style="color: rgb(0, 0, 0);">;聽}<br /></span><span style="color: rgb(0, 128, 128);">25</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽i聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;j聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">(s聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">聽bin(j)))聽{聽</span><span style="color: rgb(0, 0, 255);">continue</span><span style="color: rgb(0, 0, 0);">;聽}<br /></span><span style="color: rgb(0, 128, 128);">26</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽prob[s聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽bin(j)]聽</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">聽prob[s]聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽g[i][j]聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽bit;<br /></span><span style="color: rgb(0, 128, 128);">27</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽prob[s聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽bin(i)]聽</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">聽prob[s]聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽g[j][i]聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽bit;<br /></span><span style="color: rgb(0, 128, 128);">28</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">29</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">30</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">31</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽n;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">32</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%.6f聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽prob[bin(i)]);<br /></span><span style="color: rgb(0, 128, 128);">33</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">34</span>聽<span style="color: rgb(0, 0, 0);">聽聽putchar(</span><span style="color: rgb(0, 0, 0);">10</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">35</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">36</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">37</span>聽<span style="color: rgb(0, 0, 0);"></span></span></div><br /><img src ="http://www.shnenglu.com/schindlerlee/aggbug/119515.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/schindlerlee/" target="_blank">schindlerlee</a> 2010-07-07 01:34 <a href="http://www.shnenglu.com/schindlerlee/archive/2010/07/07/119515.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>2010-06-21 20:10:05 鍏充簬Aho-Corasick (AC) 鑷姩鏈虹殑涓夐亾棰樼洰http://www.shnenglu.com/schindlerlee/archive/2010/06/21/118385.htmlschindlerleeschindlerleeMon, 21 Jun 2010 12:13:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/06/21/118385.htmlhttp://www.shnenglu.com/schindlerlee/comments/118385.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/06/21/118385.html#Feedback0http://www.shnenglu.com/schindlerlee/comments/commentRss/118385.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/118385.html闃呰鍏ㄦ枃

]]>
2010-06-16 12:04:40 pku3528 涓夌淮鍑稿寘http://www.shnenglu.com/schindlerlee/archive/2010/06/16/118015.htmlschindlerleeschindlerleeWed, 16 Jun 2010 04:02:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/06/16/118015.htmlhttp://www.shnenglu.com/schindlerlee/comments/118015.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/06/16/118015.html#Feedback2http://www.shnenglu.com/schindlerlee/comments/commentRss/118015.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/118015.html涓夌淮鍑稿寘鐨勬眰瑙e鏋滄湁鍥涚偣鍏遍潰錛岄偅涔堝氨姣旇緝綣佺悙浜嗐?br />澧為噺娉曪紝姣忔娣誨姞涓涓偣錛岀劧鍚庢洿鏂板嚫鍖呫?br />鍏充簬澧為噺娉曠殑鍥劇ず鐪嬭繖閲?
http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html

鐜板湪鐨勪富瑕侀棶棰樺氨鏄紝涓鐩存墍鏈夐潰鐨勬硶鍚戦噺錛屽浣曟洿鏂板嚫鍖呫?br />娉曞悜閲忕偣涔樹竴涓悜閲忥紝鍙互寰楀埌榪欎釜鍚戦噺鍦ㄦ硶鍚戦噺涓婄殑鍋忕Щ錛屽鏋滆繖涓亸縐繪槸姝g殑錛岃鏄庤繖涓悜閲忕浉鍏崇殑鐐瑰湪闈㈢殑涓婃柟錛岃礋鐨勬槸涓嬫柟錛屾墍浠ュ彧瑕佹壘鍒頒竴鏉¤竟鍏寵仈鐨勪袱涓潰鐨勭偣縐槸涓姝d竴璐熷嵆鍙?br />
娉ㄦ剰榪欓噷鐨勬墍鏈夐潰閮芥槸鐢變笁涓偣緇勬垚錛屼笖鏄湁搴忕殑錛屾瘡涓竟鍙璁板綍涓ゆ錛屼竴嬈¢『鏃墮拡錛屼竴嬈¢嗘椂閽堛?br />榪欓噷涓嶈兘浣跨敤int錛屾暟鍊煎お澶т細瓚婄晫銆?br />
聽1
聽2constint聽N聽=1024;
聽3struct聽F聽{
聽4聽聽聽聽int聽v[4];
聽5聽聽聽聽F(){}
聽6聽聽聽聽F(int聽a,int聽b,int聽c){聽v[0]聽=聽a,聽v[1]聽=聽b,聽v[2]聽=聽c,聽v[3]聽=聽v[0];}
聽7};
聽8
聽9struct聽point_t聽{
10聽聽聽聽double聽x,聽y,聽z;
11聽聽聽聽point_t聽(){}
12聽聽聽聽point_t聽(double聽a,聽double聽b,聽double聽c){x聽=聽a,聽y聽=聽b,聽z聽=聽c;}
13};
14point_t聽operator+(point_t聽a,聽point_t聽b)聽{聽return聽point_t聽(a.x聽+聽b.x,聽a.y聽+聽b.y,聽a.z聽+聽b.z);}
15point_t聽operator-(point_t聽a,聽point_t聽b)聽{聽return聽point_t聽(a.x聽-聽b.x,聽a.y聽-聽b.y,聽a.z聽-聽b.z);}
16
17double聽dot_mul(point_t聽a,聽point_t聽b)聽{聽return聽a.x聽*聽b.x聽+聽a.y聽*聽b.y聽+聽a.z聽*聽b.z;}
18point_t聽cross_mul(point_t聽a,point_t聽b)
19{
20聽聽聽聽return聽point_t聽(a.y*b.z聽-聽b.y*a.z聽,
21聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽a.z*b.x聽-聽b.z*a.x聽,
22聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽a.x*b.y聽-聽b.x*a.y);
23}
24
25double聽area(point_t聽a,聽point_t聽b)
26{
27聽聽point_t聽v聽=聽cross_mul(a,聽b);
28聽聽return聽sqrt(0.0+聽v.x聽*聽v.x聽+聽v.y聽*聽v.y聽+聽v.z聽*聽v.z)聽/2;
29}
30
31point_t聽p[N];
32int聽vis[N][N],聽n;
33
34int聽main()
35{
36聽聽int聽i,聽j,聽k;
37聽聽scanf("%d",聽&n);
38聽聽for聽(i聽=0;i聽<聽n;i++)聽{
39聽聽聽聽聽聽scanf("%lf聽%lf聽%lf",聽&p[i].x,聽&p[i].y,聽&p[i].z);
40聽聽}
41聽聽vector<F>聽cur;
42聽聽cur.pb(F(0,聽1,聽2)),聽cur.pb(F(2,聽1,聽0));
43聽聽for聽(i聽=3;i聽<聽n;i++)聽{
44聽聽聽聽聽聽vector<F>聽next;
45聽聽聽聽聽聽for聽(j聽=0;j聽<聽cur.size();j++)聽{
46聽聽聽聽聽聽聽聽聽聽F聽f聽=聽cur[j];
47聽聽聽聽聽聽聽聽聽聽point_t聽v聽=聽cross_mul(p[f.v[1]]聽-聽p[f.v[0]],
48聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽p[f.v[2]]聽-聽p[f.v[1]]);
49聽聽聽聽聽聽聽聽聽聽int聽val聽=聽dot_mul(v,聽p[i]聽-聽p[f.v[1]])聽<0?-1聽:聽1;
50聽聽聽聽聽聽聽聽聽聽if聽(val聽<0)聽{
51聽聽聽聽聽聽聽聽聽聽聽聽聽聽next.pb(f);
52聽聽聽聽聽聽聽聽聽聽}
53聽聽聽聽聽聽聽聽聽聽for聽(k聽=0;k聽<3;k++)聽{
54聽聽聽聽聽聽聽聽聽聽聽聽聽聽if聽(vis[f.v[k+1]][f.v[k]]聽==0)聽{
55聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽vis[f.v[k]][f.v[k+1]]聽=聽val;
56聽聽聽聽聽聽聽聽聽聽聽聽聽聽}else聽{ //http://www.shnenglu.com/schindlerlee
57聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽if聽(vis[f.v[k+1]][f.v[k]]聽!=聽val)聽{
58聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽if聽(val聽>0)聽{
59聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽next.pb(F(f.v[k],聽f.v[k+1],聽i));
60聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}else聽{
61聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽next.pb(F(f.v[k+1],聽f.v[k],聽i));
62聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
63聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
64聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽vis[f.v[k+1]][f.v[k]]聽=0;
65聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
66聽聽聽聽聽聽聽聽聽聽}
67聽聽聽聽聽聽}
68聽聽聽聽聽聽cur聽=聽next;
69聽聽}
70聽聽double聽ans聽=0;
71聽聽for聽(i聽=0;i聽<聽cur.size();i++)聽{
72聽聽聽聽聽聽F聽f聽=聽cur[i];
73聽聽聽聽聽聽ans聽+=聽area(p[f.v[0]]聽-聽p[f.v[1]],聽p[f.v[2]]聽-聽p[f.v[1]]);
74聽聽}
75聽聽printf("%.3f\n",聽ans);
76聽聽return0;
77}




]]>
2010-06-11 00:40 spoj1182 ,dp, number theory, binary search 鏁頒綅綾葷粺璁¢棶棰?/title><link>http://www.shnenglu.com/schindlerlee/archive/2010/06/11/117608.html</link><dc:creator>schindlerlee</dc:creator><author>schindlerlee</author><pubDate>Thu, 10 Jun 2010 16:39:00 GMT</pubDate><guid>http://www.shnenglu.com/schindlerlee/archive/2010/06/11/117608.html</guid><wfw:comment>http://www.shnenglu.com/schindlerlee/comments/117608.html</wfw:comment><comments>http://www.shnenglu.com/schindlerlee/archive/2010/06/11/117608.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/schindlerlee/comments/commentRss/117608.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/schindlerlee/services/trackbacks/117608.html</trackback:ping><description><![CDATA[璇﹁鍥藉闆嗚闃?009璁烘枃闆?14.鍒樿仾 <<嫻呰皥鏁頒綅綾葷粺璁¢棶棰?gt;> <br />榪欏埌棰橀渶瑕侀潪甯告敞鎰忓鏁扮殑鎿嶄綔錛屽叾瀹炲畬鍏ㄥ彲浠ヨ璐熸暟杞寲涓烘暣鏁版搷浣?br />涔熷氨鏄痠nt杞崲鎴恥nsigned int<br />榪樻湁灝辨槸瑕佹敞鎰忥紝int鍨嬫鏁幫紝鍙崇Щ琛?錛岃礋鏁板彸縐繪槸琛?鐨勶紝<br /><div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">聽聽1</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽聽2</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽聽3</span>聽<span style="color: rgb(0, 128, 0);">聽*聽SOUR:spoj1182<br /></span><span style="color: rgb(0, 128, 128);">聽聽4</span>聽<span style="color: rgb(0, 128, 0);">聽*聽ALGO:dp,聽number聽theory,聽binary聽search<br /></span><span style="color: rgb(0, 128, 128);">聽聽5</span>聽<span style="color: rgb(0, 128, 0);">聽*聽DATE:聽2010騫綽?6鏈埪?8鏃ヂ犳槦鏈熶簩聽19:47:51聽CST<br /></span><span style="color: rgb(0, 128, 128);">聽聽6</span>聽<span style="color: rgb(0, 128, 0);">聽*聽COMM:5<br /></span><span style="color: rgb(0, 128, 128);">聽聽7</span>聽<span style="color: rgb(0, 128, 0);">聽*聽</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽聽8</span>聽<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">iostream</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽聽9</span>聽<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">cstdio</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽10</span>聽<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">cstdlib</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽11</span>聽<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">cstring</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽12</span>聽<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">algorithm</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽13</span>聽<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">queue</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽14</span>聽<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">vector</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽15</span>聽<span style="color: rgb(0, 0, 0);">#include</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">map</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽16</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">聽std;<br /></span><span style="color: rgb(0, 128, 128);">聽17</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">#define</span><span style="color: rgb(0, 0, 0);">聽pb(x)聽push_back(x)</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽18</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">#define聽X聽first<br /></span><span style="color: rgb(0, 128, 128);">聽19</span>聽<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">#define聽Y聽second</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽20</span>聽<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">typedef聽vector聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">vi;<br /></span><span style="color: rgb(0, 128, 128);">聽21</span>聽<span style="color: rgb(0, 0, 0);">typedef聽pair聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">pii;<br /></span><span style="color: rgb(0, 128, 128);">聽22</span>聽<span style="color: rgb(0, 0, 0);">typedef聽</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">聽LL;<br /></span><span style="color: rgb(0, 128, 128);">聽23</span>聽<span style="color: rgb(0, 0, 0);">typedef聽unsigned聽</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">聽ULL;<br /></span><span style="color: rgb(0, 128, 128);">聽24</span>聽<span style="color: rgb(0, 0, 0);">typedef聽unsigned聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">uint</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽25</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽26</span>聽<span style="color: rgb(0, 0, 0);">template聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽T</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽ckmin(T聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">a,T聽b)聽{聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(a聽</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽b)聽{聽a聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽b;聽}聽}<br /></span><span style="color: rgb(0, 128, 128);">聽27</span>聽<span style="color: rgb(0, 0, 0);">template聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽T</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽ckmax(T聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">a,T聽b)聽{聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(a聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽b)聽{聽a聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽b;聽}聽}<br /></span><span style="color: rgb(0, 128, 128);">聽28</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽countbit(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽n)聽{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽n聽</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">聽:聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽countbit(n聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">聽(n聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">));聽}<br /></span><span style="color: rgb(0, 128, 128);">聽29</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽30</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽maxint聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0x7fffffff</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽31</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">聽max64聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽0x7fffffffffffffffll;<br /></span><span style="color: rgb(0, 128, 128);">聽32</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽cnt[</span><span style="color: rgb(0, 0, 0);">40</span><span style="color: rgb(0, 0, 0);">][</span><span style="color: rgb(0, 0, 0);">40</span><span style="color: rgb(0, 0, 0);">],聽sum[</span><span style="color: rgb(0, 0, 0);">40</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">聽33</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽X,聽Y,聽K;<br /></span><span style="color: rgb(0, 128, 128);">聽34</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽35</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽pre()<br /></span><span style="color: rgb(0, 128, 128);">聽36</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">綆楀嚭cnt[闀垮害][鍚灝戜釜1]鐨勬柟妗堟暟</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽37</span>聽<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">聽38</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,j;<br /></span><span style="color: rgb(0, 128, 128);">聽39</span>聽<span style="color: rgb(0, 0, 0);">聽聽cnt[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">][</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽40</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">32</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽41</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽cnt[i][</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽cnt[i</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">][</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">聽42</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;j聽</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">32</span><span style="color: rgb(0, 0, 0);">;j</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽43</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽cnt[i][j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽cnt[i</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">][j]聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽cnt[i</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">][j</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">聽44</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽45</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽46</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">聽47</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽48</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽num[</span><span style="color: rgb(0, 0, 0);">40</span><span style="color: rgb(0, 0, 0);">],聽top;<br /></span><span style="color: rgb(0, 128, 128);">聽49</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽summ(</span><span style="color: rgb(0, 0, 255);">uint</span><span style="color: rgb(0, 0, 0);">聽X,聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽R,聽</span><span style="color: rgb(0, 0, 255);">bool</span><span style="color: rgb(0, 0, 0);">聽flag聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 128, 128);">聽50</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">聽51</span>聽<span style="color: rgb(0, 0, 0);">聽聽memset(num,聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 255);">sizeof</span><span style="color: rgb(0, 0, 0);">(num));<br /></span><span style="color: rgb(0, 128, 128);">聽52</span>聽<span style="color: rgb(0, 0, 0);">聽聽top聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽53</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">聽(X)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽54</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽num[top</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽X聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽55</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽X聽</span><span style="color: rgb(0, 0, 0);">>>=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽56</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽57</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(flag)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽58</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">聽top;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽59</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(num[i]聽</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽60</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽num[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽61</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽j聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽i聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;j聽</span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;j</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽62</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽num[j]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽63</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽64</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">聽top)聽{聽top</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">;聽}<br /></span><span style="color: rgb(0, 128, 128);">聽65</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽66</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽67</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽68</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽69</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽ans聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,聽one聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,聽i;<br /></span><span style="color: rgb(0, 128, 128);">聽70</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽top聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽71</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(R聽</span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);">聽one聽</span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);">聽num[i]聽</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽72</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽ans聽</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">聽cnt[i聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">][R聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽one];<br /></span><span style="color: rgb(0, 128, 128);">聽73</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽one</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽74</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽75</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽76</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽ans;<br /></span><span style="color: rgb(0, 128, 128);">聽77</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">聽78</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽79</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽summarize(</span><span style="color: rgb(0, 0, 255);">uint</span><span style="color: rgb(0, 0, 0);">聽X,聽</span><span style="color: rgb(0, 0, 255);">uint</span><span style="color: rgb(0, 0, 0);">聽Y,聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽digit)<br /></span><span style="color: rgb(0, 128, 128);">聽80</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">[X,聽Y]聽涓?鐨勪釜鏁頒負digit鐨劼犳暟瀛椾釜鏁?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽81</span>聽<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽summ(Y,聽digit,聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽summ(X,聽digit,聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">);聽}<br /></span><span style="color: rgb(0, 128, 128);">聽82</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽83</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽proc()<br /></span><span style="color: rgb(0, 128, 128);">聽84</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">聽85</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,聽j,聽one聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽86</span>聽<span style="color: rgb(0, 0, 0);">聽聽memset(sum,聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 255);">sizeof</span><span style="color: rgb(0, 0, 0);">(sum));<br /></span><span style="color: rgb(0, 128, 128);">聽87</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">32</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">聽88</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽sum[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽summarize(X,聽Y,聽i)聽;<br /></span><span style="color: rgb(0, 128, 128);">聽89</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(K聽聽</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽sum[i])聽{<br /></span><span style="color: rgb(0, 128, 128);">聽90</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽K聽</span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);">聽sum[i];<br /></span><span style="color: rgb(0, 128, 128);">聽91</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">聽{<br /></span><span style="color: rgb(0, 128, 128);">聽92</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽one聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽i;<br /></span><span style="color: rgb(0, 128, 128);">聽93</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽94</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽95</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">聽96</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(Y聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽X)聽{聽swap(X,聽Y);聽}<br /></span><span style="color: rgb(0, 128, 128);">聽97</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽left聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽X,聽right聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽Y;<br /></span><span style="color: rgb(0, 128, 128);">聽98</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">聽(left聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽right)聽{聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">binary聽search聽the聽value聽expected</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽99</span>聽<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽mid聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽(left聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽right聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">100</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(summarize(X,聽mid,聽one)聽</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">聽K)聽{<br /></span><span style="color: rgb(0, 128, 128);">101</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽left聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽mid;<br /></span><span style="color: rgb(0, 128, 128);">102</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">聽{<br /></span><span style="color: rgb(0, 128, 128);">103</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽right聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽mid聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">104</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">105</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">106</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">聽(countbit(left)聽</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">聽one)聽{聽left聽</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">;聽}聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽attention</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">107</span>聽<span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">108</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽ans聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">109</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">32</span><span style="color: rgb(0, 0, 0);">;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">110</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(left聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">聽(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);"><<</span><span style="color: rgb(0, 0, 0);">聽i))聽{<br /></span><span style="color: rgb(0, 128, 128);">111</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽ans聽</span><span style="color: rgb(0, 0, 0);">|=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);"><<</span><span style="color: rgb(0, 0, 0);">聽i;<br /></span><span style="color: rgb(0, 128, 128);">112</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">113</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">114</span>聽<span style="color: rgb(0, 0, 0);">聽聽printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽ans);<br /></span><span style="color: rgb(0, 128, 128);">115</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">116</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">117</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽main()<br /></span><span style="color: rgb(0, 128, 128);">118</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">119</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,聽j,聽testcase;<br /></span><span style="color: rgb(0, 128, 128);">120</span>聽<span style="color: rgb(0, 0, 0);">聽聽pre();<br /></span><span style="color: rgb(0, 128, 128);">121</span>聽<span style="color: rgb(0, 0, 0);">聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">testcase);<br /></span><span style="color: rgb(0, 128, 128);">122</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">聽(testcase</span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">聽)聽{<br /></span><span style="color: rgb(0, 128, 128);">123</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d聽%d聽%d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">X,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">Y,聽</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">K);<br /></span><span style="color: rgb(0, 128, 128);">124</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽proc();<br /></span><span style="color: rgb(0, 128, 128);">125</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">126</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">127</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">128</span>聽<span style="color: rgb(0, 0, 0);"></span></div><br /><img src ="http://www.shnenglu.com/schindlerlee/aggbug/117608.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/schindlerlee/" target="_blank">schindlerlee</a> 2010-06-11 00:39 <a href="http://www.shnenglu.com/schindlerlee/archive/2010/06/11/117608.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>2010-06-08 23:24:36.ural1057 number theory and dphttp://www.shnenglu.com/schindlerlee/archive/2010/06/08/117435.htmlschindlerleeschindlerleeTue, 08 Jun 2010 15:31:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/06/08/117435.htmlhttp://www.shnenglu.com/schindlerlee/comments/117435.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/06/08/117435.html#Feedback0http://www.shnenglu.com/schindlerlee/comments/commentRss/117435.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/117435.html涓嶈浜嗭紝璇﹁鍥藉闆嗚闃?009璁烘枃闆?14.鍒樿仾 <<嫻呰皥鏁頒綅綾葷粺璁¢棶棰?gt;>
闇瑕侀潪甯告敞鎰忚竟鐣屾潯浠剁殑澶勭悊.
聽聽1/*
聽聽2聽*聽SOUR:ural聽1057
聽聽3聽*聽ALGO:number聽theory聽and聽binary聽tree,聽in聽other聽word聽enumerate聽the聽highest聽digit,
聽聽4聽*聽聽聽聽聽聽and聽use聽dp聽to聽reduce聽calculation.
聽聽5聽*聽DATE:聽2010騫綽?6鏈埪?8鏃ヂ犳槦鏈熶簩聽16:44:45聽CST
聽聽6聽*聽COMM:
聽聽7聽*聽*/
聽聽8
聽聽9usingnamespace聽std;
聽10#define聽pb(x)聽push_back(x)
聽11#define聽X聽first
聽12#define聽Y聽second
聽13typedef聽vector聽<int>vi;
聽14typedef聽pair聽<int,聽int>pii;
聽15typedef聽longlong聽LL;
聽16template聽<class聽T>void聽ckmin(T聽&a,T聽b)聽{聽if聽(a聽>聽b)聽{聽a聽=聽b;聽}聽}
聽17template聽<class聽T>void聽ckmax(T聽&a,T聽b)聽{聽if聽(a聽<聽b)聽{聽a聽=聽b;聽}聽}
聽18int聽countbit(int聽n)聽{聽return聽n聽==0?0聽:聽1+聽countbit(n聽&聽(n聽-1));聽}
聽19
聽20constint聽maxint聽=0x7fffffff;
聽21constlonglong聽max64聽=聽0x7fffffffffffffffll;
聽22int聽X,聽Y,聽K,聽B;
聽23int聽cnt[40][40];
聽24
聽25void聽pre聽()
聽26{
聽27聽聽int聽i,聽j;
聽28聽聽cnt[0][0]聽=1;
聽29聽聽for聽(i聽=1;i聽<=32;i++)聽{
聽30聽聽聽聽聽聽cnt[i][0]聽=聽cnt[i-1][0];
聽31聽聽聽聽聽聽for聽(j聽=1;j聽<=32;j++)聽{
聽32聽聽聽聽聽聽聽聽聽聽cnt[i][j]聽=聽cnt[i-1][j]聽+聽cnt[i-1][j-1];
聽33聽聽聽聽聽聽}
聽34聽聽}
聽35}
聽36
聽37void聽changeBase(int聽X,聽int聽num[],聽int&top)
聽38{
聽39聽聽top聽=1;
聽40聽聽while聽(X聽>0)聽{
聽41聽聽聽聽聽聽num[top++]聽=聽X聽%聽B;
聽42聽聽聽聽聽聽X聽/=聽B;
聽43聽聽}
聽44}
聽45
聽46void聽plus_one(int聽num[],聽int&top)
聽47{
聽48聽聽int聽i,j;
聽49聽聽for聽(i聽=1;i聽<=聽top;i++)聽{
聽50聽聽聽聽聽聽if聽(num[i]聽==0)聽{
聽51聽聽聽聽聽聽聽聽聽聽num[i]聽=1;
聽52聽聽聽聽聽聽聽聽聽聽for聽(j聽=聽i聽-1;j聽>=1;j--)聽{
聽53聽聽聽聽聽聽聽聽聽聽聽聽聽聽num[j]聽=0;
聽54聽聽聽聽聽聽聽聽聽聽}
聽55聽聽聽聽聽聽聽聽聽聽break;
聽56聽聽聽聽聽聽}
聽57聽聽}
聽58聽聽if聽(i聽==聽top)聽{
聽59聽聽聽聽聽聽top++;
聽60聽聽}
聽61}
聽62
聽63bool聽floor(int聽num[],聽int聽top)
聽64{
聽65聽聽int聽i,j;
聽66聽聽for聽(i聽=聽top聽-1;i聽>=1;i--)聽{
聽67聽聽聽聽聽聽if聽(num[i]聽>1)聽{
聽68聽聽聽聽聽聽聽聽聽聽for聽(j聽=聽i;j聽>=1;j--)聽{
聽69聽聽聽聽聽聽聽聽聽聽聽聽聽聽num[j]聽=1;
聽70聽聽聽聽聽聽聽聽聽聽}
聽71聽聽聽聽聽聽聽聽聽聽break;
聽72聽聽聽聽聽聽}
聽73聽聽}
聽74聽聽if聽(i聽>=1)聽{
聽75聽聽聽聽聽聽returntrue;
聽76聽聽}
聽77聽聽returnfalse;
聽78}
聽79
聽80int聽num[40],聽top;
聽81int聽proc(int聽X,bool聽flag聽=false)
聽82{
聽83聽聽memset(num,聽0,聽sizeof(num));
聽84聽聽changeBase(X,聽num,聽top);
聽85聽聽if聽(floor(num,聽top)聽||聽flag)聽{
聽86聽聽聽聽聽聽plus_one(num,聽top);
聽87聽聽}
聽88
聽89聽聽int聽ans聽=0,聽sum聽=0,聽i;
聽90聽聽for聽(i聽=聽top聽-1;i聽>=1;i--)聽{
聽91聽聽聽聽聽聽if聽(K聽>=聽sum聽&&聽num[i]聽==1)聽{
聽92聽聽聽聽聽聽聽聽聽聽ans聽+=聽cnt[i-1][K聽-聽sum];
聽93聽聽聽聽聽聽聽聽聽聽sum++;
聽94聽聽聽聽聽聽}
聽95聽聽}
聽96聽聽return聽ans;
聽97}
聽98
聽99int聽main()
100{
101聽聽pre();
102聽聽int聽num[40],聽top,聽ans;
103聽聽cin聽>>聽X聽>>聽Y聽>>聽K聽>>聽B;
104聽聽ans聽=聽proc(Y,聽1)聽-聽proc(X);
105聽聽cout聽<<聽ans聽<<聽endl;
106聽聽return0;
107}




]]>
2010騫?3鏈?9鏃ユ槦鏈熶竴.pku2166 鏋勯?/title><link>http://www.shnenglu.com/schindlerlee/archive/2010/03/29/110773.html</link><dc:creator>schindlerlee</dc:creator><author>schindlerlee</author><pubDate>Sun, 28 Mar 2010 16:51:00 GMT</pubDate><guid>http://www.shnenglu.com/schindlerlee/archive/2010/03/29/110773.html</guid><wfw:comment>http://www.shnenglu.com/schindlerlee/comments/110773.html</wfw:comment><comments>http://www.shnenglu.com/schindlerlee/archive/2010/03/29/110773.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/schindlerlee/comments/commentRss/110773.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/schindlerlee/services/trackbacks/110773.html</trackback:ping><description><![CDATA[2010騫?3鏈?9鏃ユ槦鏈熶竴.pku2166 鏋勯?br />棰樻剰:瑕佹眰涓涓簭鍒楋紝浣胯繖涓簭鍒楄繘琛宧eapsort 榪涜浜ゆ崲鐨勬鏁版渶澶с?br />鎴戠湅鍒伴鐩腑鏈変袱涓牱渚嬭緭鍑?br />n = 5: 5 4 3 2 1<br />n = 6: 6 5 3 2 4 1<br />鎴戝彂鐜板鏋滄妸6鍘繪帀錛屾崲涓?錛屽啀緲諱笅鍘誨氨鏄?銆?br />浜庢槸鎴戞兂濂藉儚鍙互閫掓帹錛岀劧鍚庡氨榪囦簡銆傘?br />POJ bug鐪熷錛屼笅闈㈢殑浠g爜絎竴嬈′氦TLE錛岀浜屾375MS聽聽 聽<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">聽1</span>聽<span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">聽2</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">const</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽N聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">50100</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽3</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽a[N],n,len;<br /></span><span style="color: rgb(0, 128, 128);">聽4</span>聽<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽main()<br /></span><span style="color: rgb(0, 128, 128);">聽5</span>聽<span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">聽6</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i,j,k;<br /></span><span style="color: rgb(0, 128, 128);">聽7</span>聽<span style="color: rgb(0, 0, 0);">聽聽scanf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">n);<br /></span><span style="color: rgb(0, 128, 128);">聽8</span>聽<span style="color: rgb(0, 0, 0);">聽聽a[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">,len聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">聽9</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(k聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">;k聽</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">聽n;k</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">10</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽len;<br /></span><span style="color: rgb(0, 128, 128);">11</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">12</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽a[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽a[i</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">];<br /></span><span style="color: rgb(0, 128, 128);">13</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽i聽</span><span style="color: rgb(0, 0, 0);">/=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">14</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽}<br /></span><span style="color: rgb(0, 128, 128);">15</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽a[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽k;<br /></span><span style="color: rgb(0, 128, 128);">16</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽a[</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">len]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">17</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">18</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;i聽</span><span style="color: rgb(0, 0, 0);"><=</span><span style="color: rgb(0, 0, 0);">聽len;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽{<br /></span><span style="color: rgb(0, 128, 128);">19</span>聽<span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽printf(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">%d聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,a[i]);<br /></span><span style="color: rgb(0, 128, 128);">20</span>聽<span style="color: rgb(0, 0, 0);">聽聽}<br /></span><span style="color: rgb(0, 128, 128);">21</span>聽<span style="color: rgb(0, 0, 0);">聽聽putchar(</span><span style="color: rgb(0, 0, 0);">10</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">22</span>聽<span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">23</span>聽<span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">24</span>聽<span style="color: rgb(0, 0, 0);"></span></div><br /><img src ="http://www.shnenglu.com/schindlerlee/aggbug/110773.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/schindlerlee/" target="_blank">schindlerlee</a> 2010-03-29 00:51 <a href="http://www.shnenglu.com/schindlerlee/archive/2010/03/29/110773.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>2010騫?3鏈?8鏃ユ槦鏈熸棩.codeforces beta6http://www.shnenglu.com/schindlerlee/archive/2010/03/28/110710.htmlschindlerleeschindlerleeSat, 27 Mar 2010 17:17:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/03/28/110710.htmlhttp://www.shnenglu.com/schindlerlee/comments/110710.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/03/28/110710.html#Feedback3http://www.shnenglu.com/schindlerlee/comments/commentRss/110710.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/110710.html2010騫?3鏈?8鏃ユ槦鏈熸棩.codeforces beta6

A:涓夎褰袱杈逛箣鍜屽ぇ浜庣涓夎竟
B:鏆村姏鎼滀竴涓?br />C:妯℃嫙

聽1
聽2scanf("%d\n",&n);
聽3for聽(i聽=0;i聽<聽n;i++)聽{
聽4聽聽scanf("%d",a聽+聽i);
聽5}
聽6int聽L聽=0,R聽=聽n聽-1,time1聽=0,time2聽=0,ans1聽=0,ans2聽=0;
聽7while聽(L聽<=聽R)聽{
聽8聽聽if聽(time1聽<聽time2)聽{
聽9聽聽聽聽聽聽time1聽+=聽a[L++]聽,ans1聽++;
10聽聽}elseif聽(time1聽>聽time2)聽{
11聽聽聽聽聽聽time2聽+=聽a[R--]聽,ans2聽++;
12聽聽}else聽{
13聽聽聽聽聽聽time1聽+=聽a[L++]聽,ans1聽++;
14聽聽}
15}
16printf("%d聽%d\n",ans1,ans2);

D:棰樼洰鏀逛簡錛屽拰姣旇禌鐨勬椂鍊欎笉涓鏍蜂簡錛屾暟鎹寖鍥村緢灝忥紝dfs
E:RMQ + binary_search
緇欏嚭n涓暟鍜屼竴涓寖鍥碖銆?br />鎵懼嚭鏈闀跨殑榪炵畫鐨勬暟錛屽叾涓渶澶у煎拰鏈灝忓肩殑宸笉瓚呰繃K
涓涓洿瑙夌殑鎯蟲硶鏄?br />for(i = 0;i < n;i++) {
聽聽 聽int L = a[i],R = a[i];
聽聽 聽for (j = i + 1;j < n && R - L <= K;j++) {
聽聽 聽聽聽 聽鏇存柊L,R
聽聽 聽}
聽聽 聽鏇存柊answer
}

浣嗘槸n鏄?0^5,n^2浼氳秴鏃躲?br />姹傚尯闂存渶澶у兼渶灝忓煎彲浠ョ敤rmq錛孫(nlogn)棰勫鐞嗭紝O(1)鐨勫緱鍒般?br />涓瀹氬瓨鍦ㄤ竴涓猨錛屼嬌寰梐 [i ... j]鍚堟硶,a[j + 1 ..n]涓嶅悎娉曘?br />濂界殑鏂規硶鏄簩鍒嗘悳绱㈠埌榪欎釜j錛屾按鐐圭殑鏂規硶鍙互浠庡悗寰鍓嶆壘j銆?

RMQ 鍙互綰挎鏍戯紝涔熷彲浠parseTable
鎬誨鏉傚害O(nlogn)
codeforces 鍙互鐪嬩唬鐮侊紝鎯崇湅鐨勪細鍘繪壘鍚с傝繖閲岀殑浜屽垎鎼滄湁trick錛屾眰鐨勬槸upper_bound涓嶆槸涓鑸啓鐨刲ower_bound,闇瑕佽皟鏁淬?br />



]]>
2010騫?3鏈?0鏃ユ槦鏈熷叚.sgu256.cc dp http://www.shnenglu.com/schindlerlee/archive/2010/03/20/110161.htmlschindlerleeschindlerleeSat, 20 Mar 2010 05:54:00 GMThttp://www.shnenglu.com/schindlerlee/archive/2010/03/20/110161.htmlhttp://www.shnenglu.com/schindlerlee/comments/110161.htmlhttp://www.shnenglu.com/schindlerlee/archive/2010/03/20/110161.html#Feedback0http://www.shnenglu.com/schindlerlee/comments/commentRss/110161.htmlhttp://www.shnenglu.com/schindlerlee/services/trackbacks/110161.html鎴戠湅鍒拌繖棰樼殑絎竴鍗拌薄灝辨槸錛岃繖鍙兘鏄釜姘撮銆備絾鏄垜閿欎簡銆?br />榪欎釜棰樹竴鐪嬪氨鏄釜dp錛屼簬鏄垜灝卞啓浜嗕釜5灞傚驚鐜殑dp錛屾媧諱笉鐭ラ亾鎬庝箞閿欎簡銆?br />鍚庢潵鐪嬪埌浜唖cau鐨勪唬鐮侊紝鍙戠幇閫掓帹寮忓熀鏈浉鍚岋紝涓嶅悓鐨勬槸浠栧啓鐨勬槸璁板繂鍖栨悳绱?
鐒跺悗鎴戜篃灝卞啓浜嗕釜璁板繂璇濇悳绱紝涔熻繃浜嗐傘?br />
聽1
聽2#include<iostream>
聽3#include<cstdio>
聽4#include<cstdlib>
聽5#include<cstring>
聽6#include<algorithm>
聽7usingnamespace聽std;
聽8typedef聽longlong聽LL;
聽9constint聽maxint聽=0x7fffffff;
10constlonglong聽max64聽=聽0x7fffffffffffffffll;
11constint聽Debug聽=1;
12constint聽M聽=228;
13constint聽N聽=13;
14constint聽inf聽=1000000;
15
16int聽dp[M][N][N][N][N],聽m,聽n,聽a[N],聽b[N];
17void聽ckmin(int&a,聽int聽b)聽{聽if聽(a聽>聽b)聽{聽a聽=聽b;聽}聽}
18int聽dfs(int聽balloon,int聽p0,int聽p1,int聽p2,int聽p3)
19{
20聽聽if聽(dp[balloon][p0][p1][p2][p3]聽<聽inf)聽{
21聽聽聽聽聽聽return聽dp[balloon][p0][p1][p2][p3];
22聽聽}
23聽聽if聽(balloon聽>=聽m)聽{
24聽聽聽聽聽聽return0;
25聽聽}
26聽聽for聽(int聽i聽=1;i聽<=聽n;i++)聽{
27聽聽聽聽聽聽if聽(b[i]聽==1&&聽(p0聽==聽i))聽{聽continue;聽}
28聽聽聽聽聽聽if聽(b[i]聽==2&&聽(p0聽==聽i聽||聽p1聽==聽i))聽{聽continue;聽}
29聽聽聽聽聽聽if聽(b[i]聽==3&&聽(p0聽==聽i聽||聽p1聽==聽i聽||聽p2聽==聽i))聽{聽continue;聽}
30聽聽聽聽聽聽if聽(b[i]聽==4&&聽(p0聽==聽i聽||聽p1聽==聽i聽||聽p2聽==聽i聽||聽p3聽==聽i))聽{聽continue;聽}
31聽聽聽聽聽聽ckmin(dp聽[balloon][p0][p1][p2][p3]聽,聽dfs(balloon聽+聽a[i],i,p0,p1,p2)聽+1);
32聽聽}
33聽聽if聽(dp聽[balloon][p0][p1][p2][p3]聽>=聽inf)聽{
34聽聽聽聽聽聽dp聽[balloon][p0][p1][p2][p3]聽=聽dfs(balloon,0,p0,p1,p2)聽+1;
35聽聽}
36聽聽return聽dp聽[balloon][p0][p1][p2][p3];
37}
38//http://www.shnenglu.com/schindlerlee
39int聽main()
40{
41聽聽聽聽int聽i,聽j,聽k,聽p[4],聽tmp;
42聽聽聽聽memset(dp,127,sizeof(dp));
43聽聽聽聽//printf("%d\n",dp[0][0][0][0][0]);
44聽聽聽聽scanf("%d聽%d",聽&m,聽&n);
45聽聽聽聽for聽(i聽=1;聽i聽<=聽n;聽i++)聽{
46聽聽聽聽聽聽聽聽scanf("%d聽%d",聽a聽+聽i,聽b聽+聽i);
47聽聽聽聽}
48
49聽聽聽聽printf("%d\n",聽聽聽聽dfs(0,0,0,0,0));
50聽聽聽聽return0;
51}
52



]]>
久久综合九色综合网站| 日韩美女18网站久久精品| 久久精品国产欧美日韩| 一本久久a久久精品亚洲| 99热成人精品免费久久| 免费精品久久天干天干| 国产精品欧美亚洲韩国日本久久 | 久久人爽人人爽人人片AV| 精品国产综合区久久久久久| 粉嫩小泬无遮挡久久久久久| 久久受www免费人成_看片中文| 欧美精品一本久久男人的天堂| 欧美日韩精品久久免费| 久久www免费人成精品香蕉| 国产精品久久久久久久| 欧美喷潮久久久XXXXx| 狠狠色丁香久久婷婷综合蜜芽五月 | 少妇熟女久久综合网色欲| 国产成人香蕉久久久久| 国内精品久久久久影院免费| 婷婷久久综合九色综合98| 一本一本久久A久久综合精品| 久久久久亚洲精品天堂久久久久久| 久久这里只精品国产99热| MM131亚洲国产美女久久| 日韩精品久久无码人妻中文字幕| 久久久亚洲裙底偷窥综合| 97久久精品人妻人人搡人人玩| 久久精品国产免费观看| 久久天天躁夜夜躁狠狠躁2022| 人妻精品久久久久中文字幕| 精品乱码久久久久久夜夜嗨| 国产成人久久精品麻豆一区| 国产精品99久久久久久宅男 | 久久精品天天中文字幕人妻 | 伊人久久综合无码成人网| 无码八A片人妻少妇久久| 久久精品亚洲AV久久久无码| 精品国产乱码久久久久软件| 无码八A片人妻少妇久久| 少妇久久久久久被弄高潮|