HDU broken line split plane

Source: Internet
Author: User
Line split plane Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others) Total submission (s): 127 accepted submission (s): 100 Problem description We have seen many questions about straight line split planes. Today's questions are slightly changed. What we need is the maximum number of N line split planes. For example, a line can divide a plane into two parts. A line can divide a plane into seven parts at most, as shown below.
  Input The first line of the input data is an integer c, indicating the number of test instances, followed by data in Row C. Each row contains an integer N (0 <n <= 10000 ), the number of broken lines.   Output For each test instance, specify the maximum number of partitions in the output plane. The output of each instance occupies one row.   Sample Input
 
212
  Sample output
 
27
The recursive formula is as follows: A [n] = A [n-1] + 2*(2 * (n-1) + 1; That is, a [n] = A [n-1] + 4 * n-3;
 # Include <iostream>  Using namespace STD;  Int  Main  (){  Int A [  10001  ]; A [  1  ] =  2 ;  For  (  Int I =  2  ; I <  10001  ; I ++ ){ A [ I] = A [ I -  1  ] +  4  * I -  3  ;;  // Cout <A [I] <Endl;  } Int N , T ; CIN > T ;  While  ( T --){ CIN > N ; Cout< A [ N ] < Endl ;}  Return  0  ;} 

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.