HDU 2050 percent line split plane: recursive

Source: Internet
Author: User
Tags split time limit

http://acm.hdu.edu.cn/showproblem.php?pid=2050

Time limit:2000/1000 MS (java/others)

Memory limit:65536/32768 K (java/others)

Problem Description

We have seen a lot of straight line split plane problem, today's topic slightly changed, we are asking for the maximum number of n-line split plane. For example, a polyline can divide the plane into two parts, and the two polylines can divide the plane into 7 parts, as shown below.

Input

The first line of input data is an integer c that represents the number of test instances, then the C row data, each containing an integer n (0<n<=10000), representing the number of polylines.

Output

For each test instance, output the maximum number of partitions for the plane, and the output of each instance occupies one row.

Sample Input

212

Sample Output

27

Refer to "Specific mathematics":

This article URL address: http://www.bianceng.cn/Programming/sjjg/201410/45443.htm

Complete code:

/*0ms,208kb*/
    
#include <cstdio>  
    
int main ()  
{  
    int t, N;  
    scanf ("%d", &t);  
    while (t--)  
    {  
        scanf ("%d", &n);  
        printf ("%d\n", N * ((n << 1)-1) + 1);  
    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.