Hangzhou Electric 1220--cube

Source: Internet
Author: User

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


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 INPUT1 2 3 Sample Output016297 The results would not exceed int type. Authorgao Bo Source Hangzhou, the third session of the program Design competition RECOMMENDIGNATIUS.L | We have carefully selected several similar problems for you:1221 1225 1222 1224 3450 Test instructions: give you a cube, cut into a small cube of unit volume, and ask for all the common vertex numbers &L  The logarithm of a small cube of t;=2. Analysis: The number of public points can only be: 0,1,2,4. The logarithm of four common points is subtracted with the total logarithm as a result; Total common point logarithm: n^3* (n^3-1)/2 (altogether there are n^3 blocks, from which 2 blocks are selected); Common point is 4 logarithm: A column has n-1 pairs (n small squares, adjacent two are a pair of matching requirements), a polygon of a total n^2 column, The bottom and left, the first three directions the same, the same can be got, so the total is: 3*n^2 (n-1);
So the result is: N^3 * (n^3-1)-3*n^2 (n-1);
1#include <stdio.h>2 intMain ()3 {4     intN;5      while(~SCANF ("%d", &N))6     {7         intnum = n*n*n* (n*n*n-1)/2-N*n* (n1)*3 ;8printf"%d\n", num);9     }Ten     return 0 ; One}

Hangzhou Electric 1220--cube

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.