题解 CF1140D 【Minimum Triangulation】

The meaning of problems: find the n-polygon is decomposed into a minimum energy (n-2) th triangle, effort is spent and where (wherein numbering is prepared in accordance with the clockwise order of the vertices of the triangle three vertex numbers of all the product of)

Consider 1, x, y and even a triangle, x, y, z and even a triangle. A weight of xy + xyz.

Changing a connection method, 1, x, z and 1, y, z. Consider a weight of xz + yz x, y≥2 time, x + y≤xy, so that the latter is superior to the former method of split split method.

So for the answer (n³-n) ÷ 3-2

AC Code:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<(n*n*n-n)/3-2;
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/jbc666/p/10936534.html