HDU 2047 percent-wire split plane (split plane)

Source: Internet
Author: User

polyline split planeTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 24706 Accepted Submission (s): 16782

problem Descriptionwe've seen a lot of straight-line split-plane problems, and this topic is slightly different today, and we're asking for the maximum number of n-polyline split planes. For example, a polyline can divide the plane into two parts, and a maximum of two polylines can be divided into 7 parts, as shown below.
 
Inputthe first line of the input data is an integer c, representing the number of test instances, followed by the C row of data, each line containing an integer n (0<n<=10000), representing the number of polylines.

Outputfor each test instance, output the maximum number of partitions for the plane, and the output for each instance takes up one row.

Sample Input
212
 Sample Output
27
 AuthorLCY The following:
When the line splits the plane, increments the n+1 polygon set X (n) is the maximum number of planes that can be divided by n lines, x (n) =x (n-1) +n and x (1) = 2; push n=1,2,3,4,...., x (n) =2,4,7,11,... N (n+1) /2+1; When you are a node of a polyline, L (n) =x (2n) -2n, because each additional 1 polylines, adds 2 straight lines, each more vertex, less than 2 faces in the case of a straight line. So the formula is introduced: 2*n*n-n+1.

AC Code:


HDU 2047 percent-wire split plane (split plane)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.