HDU polyline split Plane (Java)

Source: Internet
Author: User
Tags polyline

Problem:

As long as you find the law problem solved, in doing the problem should be careful to find the link between the number and number.


Polyline split planeTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 19927 Accepted Submission (s): 13673


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 Input
212

Sample Output
27
Code:

Import java.util.*;p ublic class main{public static void Main (string[] args) {Scanner cin=new Scanner (system.in); int n=cin . Nextint (); for (int i=0;i<n;i++) {int m=cin.nextint ();d ouble s;s=m* (m+ (m-1)) +1; System.out.printf ("%.0f\r\n", s);}}


HDU polyline split Plane (Java)

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.