Hdu 1249 triangle (DP)

Source: Internet
Author: User

1:
You can draw a circle with an inner triangle in the circle. When we put the second triangle, we convert it to turning the existing first triangle around the concentric axis a little bit to the right (the same as the left turn). Then, each side of the second triangle will intersection Two Sides of the first triangle. In this way, 3*1*2 + 2 areas are available, and 3 indicates 3 sides, 1 indicates that each side of the second triangle will intersection Two Sides of the first triangle to get a triangle. 2 indicates two triangles, + 2 indicates a region in which the outer region and the two triangles share the same region. Similarly, the third triangle will have two edges with the first and second triangles. Available: 3*2*3 + 2
Available from some, n triangles: 3 * (n-1) * n + 2
2:
Recursive Formula: a [I] = a [I-1] + (I-1) * 6
[Csharp]
# Include "stdio. h"
Int a [10010];
Int main ()
{
Int I, t, n;
A [1] = 2; a [2] = 8;
For (I = 3; I <= 10000; I ++)
A [I] = a [I-1] + 2 * (I-1) * 3;
Scanf ("% d", & t );
While (t --)
{
Scanf ("% d", & n );
Printf ("% d \ n", a [n]);
}
Return 0;
}

 

Related Article

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.