FOJ1091 Zig-Zag Lines
来源:互联网 发布:淘宝网雪纺胖妹妹长袖 编辑:程序博客网 时间:2024/04/28 09:30
What's the maximum number of regions definable by N zig-zag lines, each of which consists of two parallel infinite half-lines joined by a straight line segment?
Here is an example of 2 zig-zag lines yield 12 regions at the most.
Input
The input consists of a sequence of N (<= 10000), which is the number of the zig-zag lines, one per line.
Output
For each N, you should output the number of the maximum regions.
Sample Input
12
Sample Output
212
这题看了N久,还是没找到递推关系,不过看了某大牛的的递推思想的确是妙:先将Z线斜线段看成直线处理,生成的区域数目H(n),H(1)=6;H(n+1)=H(n)+)+(3n+1)*2+(3n+3),(3n+1)是每条新增的平行线把前H(n)个区域划分的增加的数目,这时区域里直线的数目=3n+2,最后一条斜线使得区域增加的数目=3n+3。Z中斜线是线段的M(n),M(n)=G(n)-4n,因为,每个Z有两个角,如果斜线是直线,把每个角都补上对角,发现区域里会多出2*2*n块。
M(n+1)=M(n)+9n+1.
声明:本博客内容并非原创,如涉侵权,请告知本人,将尽快删除。
- FOJ1091 Zig-Zag Lines
- FOJ Problem 1091 Zig-Zag Lines
- 4 - zig-zag conversion
- SOJ-1640 Zig-Zag
- Zig-zag扫描
- zig-zag旋转
- SOJ--Zig-Zag
- MQL5:zig-zag 指标
- 生成 ZIG-ZAG 扫描顺序MATLAB代码
- Zig-Zag(Z型)填数
- 对二维数组进行Zig-Zag扫描(C++)
- 对二维数组进行Zig-Zag扫描(C++)
- AVL树笔记(一):zig-zag,insert,find,predecessor,successor
- lines
- Leetcode_Zig Zag Conversion
- zig tag traversal a binary tree
- Lines Sample
- Defense Lines
- Tempter of the Bone
- Asp.net 中文件的上传和下载
- 心灵的归宿
- Big Number
- 让你的Dreamweaver支持更多的文档类型(像phtml,tpl等)
- FOJ1091 Zig-Zag Lines
- 五大语言入口点特征
- badi实现步骤
- 如何开展项目质量管理,初步探讨“度量”
- HTML视频播放代码
- 在VB中调用DOS命令
- blog开工了,自己祝贺自己一下
- MIPS CPI
- wxDev-C++使用技巧