HDU 1220 Cube (combinatorial mathematics)

Source: Internet
Author: User
/*
give you a square with a side length of N, cut into a small cube of n*n*n units, and ask for the logarithm of the small cube of all public vertex numbers <=2.
the number of public points may be: 0,1,2,4.
We can subtract the logarithm of four common points with the total logarithm.

Total logarithm: n^3* (n^3-1)/2 (altogether have n^3 block small square, from which to choose 2 pieces)

and 4 intersection of the cube pair is two cube coplanar situation,
so we only ask for a large cube a total of how many units area of the common surface on it,
both the number of faces of all unit cubes 6*n^3 minus the number of polygons on the large cube surface 6*n^2,

so the result is: N^3 * (n^3-1)/2-3*n^2 (n-1) * *
include <stdio.h >
# include <algorithm>
# include <string.h>
using namespace std;
int main ()
{
    int n;
    while (~SCANF ("%d", &n))
    {
        printf ("%d\n", (n*n*n* (n*n*n-1))/2-3*n*n* (n-1));
    }
    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.