﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Vontroy-随笔分类-计算几何</title><link>http://www.cppblog.com/vontroy/category/15066.html</link><description /><language>zh-cn</language><lastBuildDate>Sun, 20 Jan 2013 21:00:21 GMT</lastBuildDate><pubDate>Sun, 20 Jan 2013 21:00:21 GMT</pubDate><ttl>60</ttl><item><title>POJ 2653 Pick-up sticks 判断线段相交</title><link>http://www.cppblog.com/vontroy/archive/2010/10/03/128488.html</link><dc:creator>Vontroy</dc:creator><author>Vontroy</author><pubDate>Sun, 03 Oct 2010 08:21:00 GMT</pubDate><guid>http://www.cppblog.com/vontroy/archive/2010/10/03/128488.html</guid><wfw:comment>http://www.cppblog.com/vontroy/comments/128488.html</wfw:comment><comments>http://www.cppblog.com/vontroy/archive/2010/10/03/128488.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/vontroy/comments/commentRss/128488.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/vontroy/services/trackbacks/128488.html</trackback:ping><description><![CDATA[<div lang="en-US" class="ptt">Pick-up sticks</div>
<div class="plm">
<table align="center">
    <tbody>
        <tr>
            <td><strong>Time Limit:</strong> 3000MS</td>
            <td width="10"></td>
            <td><strong>Memory Limit:</strong> 65536K</td>
        </tr>
        <tr>
            <td><strong>Total Submissions:</strong> 4189</td>
            <td width="10"></td>
            <td><strong>Accepted:</strong> 1501</td>
        </tr>
    </tbody>
</table>
</div>
<p class="pst">Description</p>
<div lang="en-US" class="ptx">Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan has noticed that the last thrown stick is always on top but he wants to know all the sticks that are on top. Stan sticks are very, very thin such that their thickness can be neglected.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img border="0" alt="" src="http://www.cppblog.com/images/cppblog_com/vontroy/2653_1.jpg" width="333" height="270" /></div>
<p class="pst">Input</p>
<div lang="en-US" class="ptx">Input consists of a number of cases. The data for each case start with 1 &lt;= n &lt;= 100000, the number of sticks for this case. The following n lines contain four numbers each, these numbers are the planar coordinates of the endpoints of one stick. The sticks are listed in the order in which Stan has thrown them. You may assume that there are no more than 1000 top sticks. The input is ended by the case with n=0. This case should not be processed. </div>
<p class="pst">Output</p>
<div lang="en-US" class="ptx">For each input case, print one line of output listing the top sticks in the format given in the sample. The top sticks should be listed in order in which they were thrown. <br /><br />The picture to the right below illustrates the first case from input. </div>
<p class="pst">Sample Input</p>
<pre class="sio">5
1 1 4 2
2 3 3 1
1 -2.0 8 4
1 4 8 2
3 3 6 -2.0
3
0 0 1 1
1 0 2 1
2 0 3 1
0
</pre>
<p class="pst">Sample Output</p>
<pre class="sio">Top sticks: 2, 4, 5.
Top sticks: 1, 2, 3.
</pre>
<p class="pst">Hint</p>
<div lang="en-US" class="ptx">Huge input,scanf is recommended.</div>
<br />
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Codehighlighter1_0_122_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_122_Open_Text.style.display='none'; Codehighlighter1_0_122_Closed_Image.style.display='inline'; Codehighlighter1_0_122_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_0_122_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_0_122_Closed_Text.style.display='none'; Codehighlighter1_0_122_Open_Image.style.display='inline'; Codehighlighter1_0_122_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_0_122_Closed_Text">/**/</span><span id="Codehighlighter1_0_122_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000">**********************************<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />暴力就行，从第一个开始判断<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />如果两条线段相交就把前面一条筛选掉<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />判断线段相交直接贴的吉大模板。。。<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />**********************************</span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstdio</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstring</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;std;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;maxn&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">100000</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">5</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">const</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;eps</span><span style="color: #000000">=</span><span style="color: #000000">1e</span><span style="color: #000000">-</span><span style="color: #000000">10</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img id="Codehighlighter1_271_286_Open_Image" onclick="this.style.display='none'; Codehighlighter1_271_286_Open_Text.style.display='none'; Codehighlighter1_271_286_Closed_Image.style.display='inline'; Codehighlighter1_271_286_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_271_286_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_271_286_Closed_Text.style.display='none'; Codehighlighter1_271_286_Open_Image.style.display='inline'; Codehighlighter1_271_286_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">struct</span><span style="color: #000000">&nbsp;point&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_271_286_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_271_286_Open_Text"><span style="color: #000000">{&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;x,&nbsp;y;&nbsp;}</span></span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />point&nbsp;p[maxn],&nbsp;b[maxn];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">bool</span><span style="color: #000000">&nbsp;ans[maxn];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img id="Codehighlighter1_362_386_Open_Image" onclick="this.style.display='none'; Codehighlighter1_362_386_Open_Text.style.display='none'; Codehighlighter1_362_386_Closed_Image.style.display='inline'; Codehighlighter1_362_386_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_362_386_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_362_386_Closed_Text.style.display='none'; Codehighlighter1_362_386_Open_Image.style.display='inline'; Codehighlighter1_362_386_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;min(</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;a,&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;b)&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_362_386_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_362_386_Open_Text"><span style="color: #000000">{&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;a&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;b&nbsp;</span><span style="color: #000000">?</span><span style="color: #000000">&nbsp;a&nbsp;:&nbsp;b;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img id="Codehighlighter1_420_444_Open_Image" onclick="this.style.display='none'; Codehighlighter1_420_444_Open_Text.style.display='none'; Codehighlighter1_420_444_Closed_Image.style.display='inline'; Codehighlighter1_420_444_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_420_444_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_420_444_Closed_Text.style.display='none'; Codehighlighter1_420_444_Open_Image.style.display='inline'; Codehighlighter1_420_444_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;max(</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;a,&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;b)&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_420_444_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_420_444_Open_Text"><span style="color: #000000">{&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;a&nbsp;</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;b&nbsp;</span><span style="color: #000000">?</span><span style="color: #000000">&nbsp;a&nbsp;:&nbsp;b;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">bool</span><span style="color: #000000">&nbsp;inter(point&nbsp;a,&nbsp;point&nbsp;b,&nbsp;point&nbsp;c,&nbsp;point&nbsp;d)<br /><img id="Codehighlighter1_494_992_Open_Image" onclick="this.style.display='none'; Codehighlighter1_494_992_Open_Text.style.display='none'; Codehighlighter1_494_992_Closed_Image.style.display='inline'; Codehighlighter1_494_992_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_494_992_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_494_992_Closed_Text.style.display='none'; Codehighlighter1_494_992_Open_Image.style.display='inline'; Codehighlighter1_494_992_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_494_992_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_494_992_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;min(a.x,&nbsp;b.x)&nbsp;</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;max(c.x,&nbsp;d.x)&nbsp;</span><span style="color: #000000">||</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;min(a.y,&nbsp;b.y)&nbsp;</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;max(c.y,&nbsp;d.y)&nbsp;</span><span style="color: #000000">||</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;min(c.x,&nbsp;d.x)&nbsp;</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;max(a.x,&nbsp;b.x)&nbsp;</span><span style="color: #000000">||</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;min(c.y,&nbsp;d.y)&nbsp;</span><span style="color: #000000">&gt;</span><span style="color: #000000">&nbsp;max(a.y,&nbsp;b.y)&nbsp;)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;h,&nbsp;i,&nbsp;j,&nbsp;k;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;h&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(b.x&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;a.x)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(c.y&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;a.y)&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;(b.y&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;a.y)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(c.x&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;a.x);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(b.x&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;a.x)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(d.y&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;a.y)&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;(b.y&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;a.y)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(d.x&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;a.x);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;j&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(d.x&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;c.x)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(a.y&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;c.y)&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;(d.y&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;c.y)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(a.x&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;c.x);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;k&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(d.x&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;c.x)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(b.y&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;c.y)&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;(d.y&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;c.y)&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;(b.x&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;c.x);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;h&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">&lt;=</span><span style="color: #000000">&nbsp;eps&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;j&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;k&nbsp;</span><span style="color: #000000">&lt;=</span><span style="color: #000000">&nbsp;eps;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_1006_1807_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1006_1807_Open_Text.style.display='none'; Codehighlighter1_1006_1807_Closed_Image.style.display='inline'; Codehighlighter1_1006_1807_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_1006_1807_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1006_1807_Closed_Text.style.display='none'; Codehighlighter1_1006_1807_Open_Image.style.display='inline'; Codehighlighter1_1006_1807_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1006_1807_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1006_1807_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;n;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;res[maxn];<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(&nbsp;cin&nbsp;</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">&nbsp;n,&nbsp;n&nbsp;)<br /><img id="Codehighlighter1_1067_1791_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1067_1791_Open_Text.style.display='none'; Codehighlighter1_1067_1791_Closed_Image.style.display='inline'; Codehighlighter1_1067_1791_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1067_1791_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1067_1791_Closed_Text.style.display='none'; Codehighlighter1_1067_1791_Open_Image.style.display='inline'; Codehighlighter1_1067_1791_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1067_1791_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1067_1791_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memset(&nbsp;ans,&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">,&nbsp;</span><span style="color: #0000ff">sizeof</span><span style="color: #000000">(&nbsp;ans&nbsp;)&nbsp;);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;n;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">&nbsp;)<br /><img id="Codehighlighter1_1155_1222_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1155_1222_Open_Text.style.display='none'; Codehighlighter1_1155_1222_Closed_Image.style.display='inline'; Codehighlighter1_1155_1222_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1155_1222_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1155_1222_Closed_Text.style.display='none'; Codehighlighter1_1155_1222_Open_Image.style.display='inline'; Codehighlighter1_1155_1222_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1155_1222_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1155_1222_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin&nbsp;</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">&nbsp;p[i].x&nbsp;</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">&nbsp;p[i].y&nbsp;</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">&nbsp;b[i].x&nbsp;</span><span style="color: #000000">&gt;&gt;</span><span style="color: #000000">&nbsp;b[i].y;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;n;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">&nbsp;)<br /><img id="Codehighlighter1_1270_1530_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1270_1530_Open_Text.style.display='none'; Codehighlighter1_1270_1530_Closed_Image.style.display='inline'; Codehighlighter1_1270_1530_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1270_1530_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1270_1530_Closed_Text.style.display='none'; Codehighlighter1_1270_1530_Open_Image.style.display='inline'; Codehighlighter1_1270_1530_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1270_1530_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1270_1530_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;j&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;&nbsp;j&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;n;&nbsp;j</span><span style="color: #000000">++</span><span style="color: #000000">&nbsp;)<br /><img id="Codehighlighter1_1329_1520_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1329_1520_Open_Text.style.display='none'; Codehighlighter1_1329_1520_Closed_Image.style.display='inline'; Codehighlighter1_1329_1520_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1329_1520_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1329_1520_Closed_Text.style.display='none'; Codehighlighter1_1329_1520_Open_Image.style.display='inline'; Codehighlighter1_1329_1520_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1329_1520_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1329_1520_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;inter(p[i],&nbsp;b[i],&nbsp;p[j],&nbsp;b[j]&nbsp;)&nbsp;)<br /><img id="Codehighlighter1_1400_1506_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1400_1506_Open_Text.style.display='none'; Codehighlighter1_1400_1506_Closed_Image.style.display='inline'; Codehighlighter1_1400_1506_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1400_1506_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1400_1506_Closed_Text.style.display='none'; Codehighlighter1_1400_1506_Open_Image.style.display='inline'; Codehighlighter1_1400_1506_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1400_1506_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1400_1506_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ans[i]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">break</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">不加break会超时。。。</span><span style="color: #008000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;ct&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Top&nbsp;sticks:&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;n;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">&nbsp;)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;</span><span style="color: #000000">!</span><span style="color: #000000">ans[i]&nbsp;)&nbsp;&nbsp;res[ct</span><span style="color: #000000">++</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;ct&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">&nbsp;)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;res[i]&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;res[ct</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">]&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">.</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;endl;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span></div><img src ="http://www.cppblog.com/vontroy/aggbug/128488.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/vontroy/" target="_blank">Vontroy</a> 2010-10-03 16:21 <a href="http://www.cppblog.com/vontroy/archive/2010/10/03/128488.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>POJ 1269 Intersecting Lines 判断直线相交并求交点</title><link>http://www.cppblog.com/vontroy/archive/2010/10/03/128429.html</link><dc:creator>Vontroy</dc:creator><author>Vontroy</author><pubDate>Sun, 03 Oct 2010 03:03:00 GMT</pubDate><guid>http://www.cppblog.com/vontroy/archive/2010/10/03/128429.html</guid><wfw:comment>http://www.cppblog.com/vontroy/comments/128429.html</wfw:comment><comments>http://www.cppblog.com/vontroy/archive/2010/10/03/128429.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/vontroy/comments/commentRss/128429.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/vontroy/services/trackbacks/128429.html</trackback:ping><description><![CDATA[<div lang="en-US" class="ptt" align="center"><strong style="font-size: 18pt"><br />Intersecting Lines<br /><br /></strong></div>
<div class="plm">
<table align="center">
    <tbody>
        <tr>
            <td><strong>Time Limit:</strong> 1000MS</td>
            <td width="10"></td>
            <td><strong>Memory Limit:</strong> 10000K</td>
        </tr>
        <tr>
            <td><strong>Total Submissions:</strong> 4260</td>
            <td width="10"></td>
            <td><strong>Accepted:</strong> 2049</td>
        </tr>
    </tbody>
</table>
</div>
<p class="pst"><strong>Description</strong></p>
<div lang="en-US" class="ptx">We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) intersect in a line because they are on top of one another (i.e. they are the same line), 3) intersect in a point. In this problem you will use your algebraic knowledge to create a program that determines how and where two lines intersect. <br />Your program will repeatedly read in four points that define two lines in the x-y plane and determine how and where the lines intersect. All numbers required by this problem will be reasonable, say between -1000 and 1000.</div>
<p class="pst"><strong>Input</strong></p>
<div lang="en-US" class="ptx">The first line contains an integer N between 1 and 10 describing how many pairs of lines are represented. The next N lines will each contain eight integers. These integers represent the coordinates of four points on the plane in the order x1y1x2y2x3y3x4y4. Thus each of these input lines represents two lines on the plane: the line through (x1,y1) and (x2,y2) and the line through (x3,y3) and (x4,y4). The point (x1,y1) is always distinct from (x2,y2). Likewise with (x3,y3) and (x4,y4).</div>
<p class="pst"><strong>Output</strong></p>
<div lang="en-US" class="ptx">There should be N+2 lines of output. The first line of output should read INTERSECTING LINES OUTPUT. There will then be one line of output for each pair of planar lines represented by a line of input, describing how the lines intersect: none, line, or point. If the intersection is a point then your program should output the x and y coordinates of the point, correct to two decimal places. The final line of output should read "END OF OUTPUT". </div>
<p class="pst"><strong>Sample Input</strong></p>
<pre class="sio">5
0 0 4 4 0 4 4 0
5 0 7 6 1 0 2 3
5 0 7 6 3 -6 4 -3
2 0 2 27 1 5 18 5
0 3 4 0 1 2 2 5
</pre>
<p class="pst"><strong>Sample Output</strong></p>
<pre class="sio">INTERSECTING LINES OUTPUT
POINT 2.00 2.00
NONE
LINE
POINT 2.00 5.00
POINT 1.07 2.20
END OF OUTPUT
</pre>
<pre class="sio"><div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><img id="Codehighlighter1_0_107_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_107_Open_Text.style.display='none'; Codehighlighter1_0_107_Closed_Image.style.display='inline'; Codehighlighter1_0_107_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_0_107_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_0_107_Closed_Text.style.display='none'; Codehighlighter1_0_107_Open_Image.style.display='inline'; Codehighlighter1_0_107_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_0_107_Closed_Text">/**/</span><span id="Codehighlighter1_0_107_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000">************************************<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />计算几何基础题，判断直线相交及求交点<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />注意斜率不存在的情况<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />*************************************</span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">iostream</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" />#include&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">cstdio</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;main()<br /><img id="Codehighlighter1_159_1728_Open_Image" onclick="this.style.display='none'; Codehighlighter1_159_1728_Open_Text.style.display='none'; Codehighlighter1_159_1728_Closed_Image.style.display='inline'; Codehighlighter1_159_1728_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_159_1728_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_159_1728_Closed_Text.style.display='none'; Codehighlighter1_159_1728_Open_Image.style.display='inline'; Codehighlighter1_159_1728_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_159_1728_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_159_1728_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;x1,&nbsp;y1,&nbsp;x2,&nbsp;y2,&nbsp;x3,&nbsp;y3,&nbsp;x4,&nbsp;y4;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;n;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;k1,&nbsp;k2;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;b1,&nbsp;b2;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">double</span><span style="color: #000000">&nbsp;i_x,&nbsp;i_y;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%d</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">n);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">INTERSECTING&nbsp;LINES&nbsp;OUTPUT</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;std::endl;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">while</span><span style="color: #000000">(&nbsp;n</span><span style="color: #000000">--</span><span style="color: #000000">&nbsp;)<br /><img id="Codehighlighter1_375_1675_Open_Image" onclick="this.style.display='none'; Codehighlighter1_375_1675_Open_Text.style.display='none'; Codehighlighter1_375_1675_Closed_Image.style.display='inline'; Codehighlighter1_375_1675_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_375_1675_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_375_1675_Closed_Text.style.display='none'; Codehighlighter1_375_1675_Open_Image.style.display='inline'; Codehighlighter1_375_1675_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_375_1675_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_375_1675_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scanf(</span><span style="color: #000000">"</span><span style="color: #000000">%lf%lf%lf%lf%lf%lf%lf%lf</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">x1,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">y1,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">x2,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">y2,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">x3,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">y3,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">x4,&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">y4);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;x1&nbsp;</span><span style="color: #000000">!=</span><span style="color: #000000">&nbsp;x2&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;x3&nbsp;</span><span style="color: #000000">!=</span><span style="color: #000000">&nbsp;x4&nbsp;)<br /><img id="Codehighlighter1_504_1034_Open_Image" onclick="this.style.display='none'; Codehighlighter1_504_1034_Open_Text.style.display='none'; Codehighlighter1_504_1034_Closed_Image.style.display='inline'; Codehighlighter1_504_1034_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_504_1034_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_504_1034_Closed_Text.style.display='none'; Codehighlighter1_504_1034_Open_Image.style.display='inline'; Codehighlighter1_504_1034_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_504_1034_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_504_1034_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(&nbsp;y2&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;y1&nbsp;)&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">&nbsp;(&nbsp;x2&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;x1&nbsp;);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(&nbsp;y4&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;y3&nbsp;)&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">&nbsp;(&nbsp;x4&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;x3&nbsp;);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;y1&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;k1&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x1;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;y3&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;k2&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x3;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;k1&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;k2&nbsp;)<br /><img id="Codehighlighter1_695_839_Open_Image" onclick="this.style.display='none'; Codehighlighter1_695_839_Open_Text.style.display='none'; Codehighlighter1_695_839_Closed_Image.style.display='inline'; Codehighlighter1_695_839_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_695_839_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_695_839_Closed_Text.style.display='none'; Codehighlighter1_695_839_Open_Image.style.display='inline'; Codehighlighter1_695_839_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_695_839_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_695_839_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;b1&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;b2&nbsp;)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">LINE\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">NONE\n</span><span style="color: #000000">"</span><span style="color: #000000">);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000"><br /><img id="Codehighlighter1_870_1024_Open_Image" onclick="this.style.display='none'; Codehighlighter1_870_1024_Open_Text.style.display='none'; Codehighlighter1_870_1024_Closed_Image.style.display='inline'; Codehighlighter1_870_1024_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_870_1024_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_870_1024_Closed_Text.style.display='none'; Codehighlighter1_870_1024_Open_Image.style.display='inline'; Codehighlighter1_870_1024_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_870_1024_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_870_1024_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i_x&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(b2&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;b1)&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">&nbsp;(k1&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;k2);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i_y&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;k1&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;i_x&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;b1;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">POINT&nbsp;%.2lf&nbsp;%.2lf\n</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;i_x,&nbsp;i_y);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;x1&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;x2&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;x3&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;x4&nbsp;)<br /><img id="Codehighlighter1_1084_1210_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1084_1210_Open_Text.style.display='none'; Codehighlighter1_1084_1210_Closed_Image.style.display='inline'; Codehighlighter1_1084_1210_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1084_1210_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1084_1210_Closed_Text.style.display='none'; Codehighlighter1_1084_1210_Open_Image.style.display='inline'; Codehighlighter1_1084_1210_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1084_1210_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1084_1210_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;x1&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;x3&nbsp;)<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">LINE\n</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">NONE\n</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(&nbsp;x1&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;x2&nbsp;</span><span style="color: #000000">&amp;&amp;</span><span style="color: #000000">&nbsp;x3&nbsp;</span><span style="color: #000000">!=</span><span style="color: #000000">&nbsp;x4&nbsp;)<br /><img id="Codehighlighter1_1260_1453_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1260_1453_Open_Text.style.display='none'; Codehighlighter1_1260_1453_Closed_Image.style.display='inline'; Codehighlighter1_1260_1453_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1260_1453_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1260_1453_Closed_Text.style.display='none'; Codehighlighter1_1260_1453_Open_Image.style.display='inline'; Codehighlighter1_1260_1453_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1260_1453_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1260_1453_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(&nbsp;y4&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;y3&nbsp;)&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">&nbsp;(&nbsp;x4&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;x3&nbsp;);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b2&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;y3&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;k2&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x3;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i_x&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;x1;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i_y&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;k2&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x1&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;b2;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">POINT&nbsp;%.2lf&nbsp;%.2lf\n</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;i_x,&nbsp;i_y);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000"><br /><img id="Codehighlighter1_1476_1669_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1476_1669_Open_Text.style.display='none'; Codehighlighter1_1476_1669_Closed_Image.style.display='inline'; Codehighlighter1_1476_1669_Closed_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_1476_1669_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_1476_1669_Closed_Text.style.display='none'; Codehighlighter1_1476_1669_Open_Image.style.display='inline'; Codehighlighter1_1476_1669_Open_Text.style.display='inline';" align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_1476_1669_Closed_Text"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_1476_1669_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(&nbsp;y2&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;y1&nbsp;)&nbsp;</span><span style="color: #000000">/</span><span style="color: #000000">&nbsp;(&nbsp;x2&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;x1&nbsp;);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b1&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;y1&nbsp;</span><span style="color: #000000">-</span><span style="color: #000000">&nbsp;k1&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x1;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i_x&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;x3;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i_y&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;k1&nbsp;</span><span style="color: #000000">*</span><span style="color: #000000">&nbsp;x3&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;b1;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="color: #000000">"</span><span style="color: #000000">POINT&nbsp;%.2lf&nbsp;%.2lf\n</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;i_x,&nbsp;i_y);<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;std::cout&nbsp;</span><span style="color: #000000">&lt;&lt;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">END&nbsp;OF&nbsp;OUTPUT\n</span><span style="color: #000000">"</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"  alt="" /></span></div>
</pre><img src ="http://www.cppblog.com/vontroy/aggbug/128429.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/vontroy/" target="_blank">Vontroy</a> 2010-10-03 11:03 <a href="http://www.cppblog.com/vontroy/archive/2010/10/03/128429.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>