Parallel and perpendicular

Source: Internet
Author: User

Question Link

  • Question:
    Enter n to obtain the number of diagonal 1 and diagonal 2 in the positive n edge shape (diagonal 1: At least parallel to the other diagonal; diagonal 2: At least perpendicular to the other diagonal ), the diagonal line cannot be the side of a polygon.
    (4 ≤ n ≤ 10e5)
  • Analysis:
    The number of sides in the center of two parallel edges must be the same, that is to say, when the two endpoints move several short points in one direction, they can get another parallel edge. That is to say, each side of a polygon is parallel (when the six sides are in the shape of a special case, they are processed separately)
    Vertical relatively troublesome: For N is an even number, we can obtain that each point of the n-3 side is a diagonal 2 (n is an even number, any diagonal line must divide the original graph into two Symmetric Graphs); when n is an odd number, there is no diagonal line 2 (only speculation)
Int A [2] [110]; int main () {int N; A [0] [4] = 0; A [0] [5] = 0; A [0] [6] = 6; A [1] [4] = 2; A [1] [5] = 0; A [1] [6] = 9; while (~ RI (N) {If (n <= 6) {printf ("% d \ n", a [0] [N], A [1] [N]);} else {cout <1ll * (N-3) * n/2 <''; If (N & 1) cout <0 <Endl; else cout <1ll * (N-3) * 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.