HDU 12,493 Corner-shaped Division

Source: Internet
Author: User

The three edges of a triangle can be added to a graph to observe

Suppose you add the nth triangle

The first n-1 triangle divides the area into sum[n-1]

The nth triangle can pass up to two sides of each triangle on each edge of the first n-1 triangle, and one edge is cut to increase the n-1-1 area.

Then the three edges of the internal graph are cut to increase the 6* (n-1)-3 regions, and the new triangle itself in three corners of the formation of three new areas

The 6* (n-1) area has been added to a total of

Then the recursive function is

Sum[i] = sum[i-1] + 6* (i-1)

In fact, the direct point is to use the Euler formula to solve the problem

V (Point)-E (Edge) + F (face) = 2

Add nth triangles at a time

The added point is 2 * (n-1) * 3 + 3 = 6*n-3

Added side for (2*n-1) * * (new triangle added edge) + n-1 (original n-1 triangle each three edges are divided by the new triangle two times) = 6*n-9

So the last increase in the number of polygons is 6* (n-1)

1#include <cstdio>2 3 intsum[10005];4 5 intMain ()6 {7sum[1] =2;8      for(inti =2; i<=10000; i++)9Sum[i] = sum[i-1] +3*2* (I-1);Ten     intT, N; Onescanf"%d", &T); A      while(t--){ -scanf"%d", &n); -printf"%d\n", Sum[n]); the     } -     return 0; -}

HDU 12,493 Corner-shaped Division

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.