FOJ1091 Zig-Zag Lines

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

1
2

Sample Output

2
12

     

     这题看了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.

 

 

 

声明:本博客内容并非原创,如涉侵权,请告知本人,将尽快删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值