HDU2050 discrete mathematical polyline split plane

Source: Internet
Author: User
Tags polyline

Polyline split plane

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 24505 Accepted Submission (s): 16644


Problem description We've seen a lot of straight-line split-plane problems, and today the topic is slightly different, 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.

The first line of 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.

Output for each test instance, export the maximum number of partitions for the plane, one row for each instance.

Sample Input212

Sample Output27

Authorlcy

Source Recursive Solution topic exercise (for beginner)

Recommendlcy | We have carefully selected several similar problems for you:2046 2045 2044 2049 2041

The recursive formula is:

a[1]=2;
for (i=2;i<100;i++)
A[I]=4*I-3+A[I-1];
And
for (i=1;i<100;i++)
a[i]=2*i*i-i+1;
Can transform the knowledge of discrete mathematics with each other

The law is: a[n]= (n-1)-1) *2+3+a[n-1];

The two edges of the nth polyline are not parallel to all the edges of the front n-1, because they are all intersecting;

The first edge of the nth polyline intersects with the n-1 edge of the front n-1 polyline, each with two edges increases a split part, so there is a (n-1)-1 divided portion is added here, and the other side of the nth polyline is increased by the addition of the (n-1)-1 sections, The other side of the last nth polyline also extends outward infinitely, and the edges in the last n-1 polyline that intersect with them make up an extra part, and the head of the nth polyline is a separate part, so n-1-1 + 3, is more than the n-1 line divided into parts of the number of parts, so there are: a[n]= (n-1)-1) *2+3+a[n-1];

Draw a, so that each side and the other side all intersect, you can find the law.

#include <iostream>using namespacestd;intMain () {inti,n,a[10005],t;  for(i=1;i<10005; i++) A[i]=2*i*i-i+1; CIN>>T;  while(cin>>n&&t--) cout<<a[n]<<Endl; return 0;}

HDU2050 discrete mathematical polyline 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.