Split n edges

Source: Internet
Author: User

1. Question:

Problem Description takes n vertices (n> 3) of the edges and m (m) points in the edges. A total of (m + n) vertices are used as vertices, how many small triangles can be separated by the original n-sides?
Multiple Input groups exist. n and m are Input in each line, separated by spaces.
Output outputs a row of input data for each group.
Sample Input
3 24 35 62012 22
Sample Output
58152054
Authorwqq

 

 

 

2. Ideas:

This is a regular question. The specific analysis is as follows:

Question:NEdgesNVertex and its internalMPoints, total (M+N) Points as vertices.NHow many small triangles do not overlap each other?

Question inquiry: To solve the above problems, we will adopt a special strategy for general problems, starting with simple and specific situations:

 

Explore 1: Take △ABCAnd its internal point.P, A total of four vertices are vertices.ABCHow many small triangles do not overlap each other?

1. Obviously, you can set △ABCIt is divided into three small triangles that do not overlap each other.

 

Explore 2: Take △ABCThe three vertices of and the two points inside itP,Q, A total of five vertices are vertices.ABCHow many small triangles do not overlap each other?

On the basis of Inquiry 1, we can consider itABCAdd another vertex.Q, That's the pointQThere are two scenarios:

Point:QInside a small triangle split in Figure ①, set points.QIn △PACInternal, ②;

In another caseQOn a public edge of a small triangle split in Figure ①, set a point.QInPA, ③.

Obviously, in either case, △ABCIt is divided into five small triangles that do not overlap each other.

 

Explore 3: Take △ABCThe three vertices of and the three vertices inside itP,Q,R, A total of 6 vertices are vertices.ABCSplitA small triangle that does not overlap with each other, and draw a segmentation in Figure 4.

 

Explore 4: Take △ABCAnd its internalMPoints, total (M+ 3) vertex: You can set △ABCSplitA small triangle that does not overlap with each other.

 

Exploration expansion: four vertices of a quadrilateral and their internalMPoints, total (M+ 4) points are vertices. You can divide the quadrilateralA small triangle that does not overlap with each other.

 

Solution:NEdgesNVertex and its internalMPoints, total (M+N) Points as vertices.NSplit edgesA small triangle that does not overlap with each other.

 

Practical Application: How many small triangles can be divided into non-overlapping triangles by dividing the eight vertices of an aggregator and the 2012 vertices inside it with a total of 2020 vertices? (Column-based calculation is required)

 

Answer:

Explore 3: 7.

Study 4: 3 + 2 (S-1) or 2 m + 1.

Exploration expansion: 4 + 2 (S-1) or 2 m + 2.

Problem solved: n + 2 (S-1) or 2 m + N-2.

Practical Application: place n = 8, m = 2012 into the above algebraic formula:

2 m + n-2 = 2*2012 + 8-2 = 4024 + 8-2 = 4030.

 

3. Reference code:

 

 

#include <iostream>using namespace std;int main(){    int n, m;    while (cin >> n >> m) {                    cout << 2 * m + n - 2 << 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.