Pipe_梁举.doc_第1页
Pipe_梁举.doc_第2页
Pipe_梁举.doc_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

解题报告:Phone numbers题目来源: No.1039解法或类型:枚举作者:梁 举 PipeTime Limit:1S Memory Limit:1000KTotal Submit:124 Accepted:36Description The GX Light Pipeline Company started to prepare bent pipes for the new transgalactic light pipeline. During the design phase of the new pipe shape the company ran into the problem of determining how far the light can reach inside each component of the pipe. Note that the material which the pipe is made from is not transparent and not light reflecting. Each pipe component consists of many straight pipes connected tightly together. For the programming purposes, the company developed the description of each component as a sequence of points x1; y1, x2; y2, . . ., xn; yn, where x1 x2 . . . xn . These are the upper points of the pipe contour. The bottom points of the pipe contour consist of points with y-coordinate decreased by 1. To each upper point xi; yi there is a corresponding bottom point xi; (yi)-1 (see picture above). The company wants to find, for each pipe component, the point with maximal x-coordinate that the light will reach. The light is emitted by a segment source with endpoints x1; (y1)-1 and x1; y1 (endpoints are emitting light too). Assume that the light is not bent at the pipe bent points and the bent points do not stop the light beam. Input The input file contains several blocks each describing one pipe component. Each block starts with the number of bent points 2 = n = 20 on separate line. Each of the next n lines contains a pair of real values xi, yi separated by space. The last block is denoted with n = 0. Output The output file contains lines corresponding to blocks in input file. To each block in the input file there is one line in the output file. Each such line contains either a real value, written with precision of two decimal places, or the message Through all the pipe. The real value is the desired maximal x-coordinate of the point where the light can reach from the source for corresponding pipe component. If this value equals to xn, then the message Through all the pipe. will appear in the output file. Sample Input 40 12 24 16 460 12 -0.65 -4.457 -5.5712 -10.817 -16.550Sample Output 4.67Through all the pipe.Source Central Europe 1995解题思路:题目要我们求出光线在Pipe里能射到的最远处的x坐标。我们只要找出其中一条最优光线。一条最优光线必须满足的一个必要条件是:它必定过Pipe的一个上顶点和一个下顶点。否则,我们总可以通过平移或是旋转使光线走更远的距离。有了这个条件,就可以通过枚举所有的上下顶点对(i,j),找出最优的。过上下顶点的光线共有n*n条,要求的就是MaxX(i,j) | 过上下顶点对(i,j)能达到的最远距离的横坐标 (i=0.n-1,j=0.n-1;)光线(i,j)要能进入了k-1到k这一节,则它比与(0,0).(k-1,k-1)都相交。并且当(i,j)与(0,0).(k-1,k-1)都相交,而与(k,k)不交时,他必与上边或下边(k-1,k)相交。显然当kMax(i,j),求出(i,j)与上/下边(k-1,k)的交点的x坐标,并与当前最大值比较,决定取舍。在判断(i,j)与(k,k)(k=0,1,.)的交点时,可以直接求出他们所在直线的纵坐标来决定。(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论