HDU 1220 Cube Simple number theory

Source: Internet
Author: User

CubeTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 1516 Accepted Submission (s): 1206


Problem Descriptioncowl is good at solving math problems. One day a friend asked him such a question:you be given a cube whose edge length is N, it's cut by the planes Paralleled to it side planes into n * n * n unit cubes. Both unit cubes may have no common points or both common points or four common points. Your job is to calculate how many pairs of unit cubes that has no more than and common points.

Process to the end of file.

Inputthere'll be many test cases. Each test case would only be give the edge length N of a cube in one line. N is a positive integer (1<=n<=30).

Outputfor Each test case, you should output the number of pairs is described above in one line.

Sample Input
123

Sample Output
016297HintHintThe results would not exceed int type.
/* 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 there are n^3 blocks, from which 2 blocks are selected)  The common point is 4 logarithm: A column has n-1 pairs (n small squares, adjacent two for a pair of matching requirements), a face of the total n^2 column, the  bottom and the left, The first three directions are the same, so the total is: 3*n^2 (n-1)  So the result is: N^3 * (n^3-1)/2-3*n^2 (n-1) */  #include <stdio.h>int main () {int n; while (~SCANF ("%d", &n)) {printf ("%d\n", n*n*n* (n*n*n-1)/2-3* (n-1) *n*n);} return 0;}

with June

HDU 1220 Cube Simple number theory

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.