HOJ 1551 Polylops(简单数学题)
来源:互联网 发布:剑灵力士卡刀软件 编辑:程序博客网 时间:2024/05/30 04:49
Polylops
Submitted : 57, Accepted : 33
Given the vertices of a non-degenerate polygon (no 180-degree angles, zero-length sides, or self-intersection - but not necessarily convex), you must determine how many distinct lines of symmetry exist for that polygon. A line of symmetry is one on which the polygon, when reflected on that line, maps to itself.
Input
Input consists of a description of several polygons.
Each polygon description consists of two lines. The first contains the integer "n" (3 <= n <= 1000), which gives the number of vertices on the polygon. The second contains "n" pairs of numbers (an x- and a y-value), describing the vertices of the polygon in order. All coordinates are integers from -1000 to 1000.
Input terminates on a polygon with 0 vertices.
Output
For every polygon described, print out a line saying "Polygon #x has y symmetry line(s).", where x is the number of the polygon (starting from 1), and y is the number of distinct symmetry lines on that polygon.
Sample Input
4-1 0 0 2 1 0 0 -13-666 -42 57 -84 19 2823-241 -50 307 43 -334 4980Sample Output
Polygon #1 has 1 symmetry line(s).Polygon #2 has 0 symmetry line(s).Polygon #3 has 1 symmetry line(s).
既然是一道简单数学题为什么还特意写了一发题解呢。。
因为这题非常坑,有一种特别神奇的情况很难想到。
求从长方体的角沿着表面走到表面任意点的最短距离。
可以把长方体翻折开,化立体为平面,求直线距离即可。
分类讨论,在下面的三个面直接求距离,在上面的时候需要求出几种可能路径取最小值。
每个面都有四种路径,可以想一想(我当初就只想到了两种。。WA到死。。)
代码如下:
#include <iostream>#include <cstdio>using namespace std;const int INF = 0x3f3f3f3f;int main(){ int lx,ly,lz,x,y,z; while(scanf("%d%d%d%d%d%d",&lx,&ly,&lz,&x,&y,&z),lx+ly+lz+x+y+z){ int ans = INF; if(!x||!y||!z) ans = x*x+y*y+z*z; if(x == lx){ ans = min(ans,(x+y)*(x+y)+z*z); ans = min(ans,(z+x)*(z+x)+y*y); ans = min(ans,(ly+z)*(ly+z)+(x+ly-y)*(x+ly-y)); ans = min(ans,(y+lz)*(y+lz)+(x+lz-z)*(x+lz-z)); }if(y == ly) { ans = min(ans,(y+z)*(y+z)+x*x); ans = min(ans,(y+x)*(y+x)+z*z); ans = min(ans,(z+lx)*(z+lx)+(y+lx-x)*(y+lx-x)); ans = min(ans,(lz+x)*(lz+x)+(y+lz-z)*(y+lz-z)); }if(z == lz){ ans = min(ans,(z+y)*(z+y)+x*x); ans = min(ans,(z+x)*(z+x)+y*y); ans = min(ans,(y+lx)*(y+lx)+(z+lx-x)*(z+lx-x)); ans = min(ans,(ly+x)*(ly+x)+(z+ly-y)*(z+ly-y)); } printf("%d\n",ans); } return 0;}
- HOJ 1551 Polylops(简单数学题)
- Gridland 数学题 hoj
- Factstone Benchmark hoj 数学题
- 简单数学题
- 简单数学题
- Billiard hoj poj 数学题 挺好的
- Crazy Tea Party hoj poj 数学题
- 一道简单数学题
- HDU 2048 简单数学题
- hdu1009简单数学题
- hdoj1019简单数学题
- hdoj1018简单题、数学题
- hdoj1108简单题、数学题
- HDU2964Prime Bases简单数学题
- 简单的数学题
- FZU2251OOXX--简单数学题
- 一个简单的数学题
- HDU 1017 简单数学题
- UVA 10106
- MFC 写文档的方法
- BZOJ 1025: [SCOI2009]游戏
- 苹果Mac下LAMP环境的搭建
- 权限:user权限,folder 权限
- HOJ 1551 Polylops(简单数学题)
- 搜索. Poj1324. Holedox Moving.
- 简单实现窗口拖动
- 4sum
- OCP试题解析之053-61 RMAN set command id to
- 事件:事件的类型 作用
- Flash Builder4.0新建Flex应用程序切换主题出错
- Java读取txt文件中内容作为测试用例中的参数
- universe里面的限制:如何定义限制,使用限制