zoukankan      html  css  js  c++  java
  • Cube HDU

    Cowl is good at solving math problems. One day a friend asked him such a question: You are given a cube whose edge length is N, it is cut by the planes that was paralleled to its side planes into N * N * N unit cubes. Two unit cubes may have no common points or two common points or four common points. Your job is to calculate how many pairs of unit cubes that have no more than two common points. 

    Process to the end of file. 

    InputThere will be many test cases. Each test case will only 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 that was described above in one line. 
    Sample Input

    1
    2
    3

    Sample Output

    0
    16
    297
    
    
            
     
    The results will not exceed int type.

    Hint

    Hint
            
     


    题意:长度为n的立方体切为n*n*n个长度为1的立方体,求相邻的点小于等于两个的个数
    题解:相反考虑,排列组合,结合切好后的总表面积和一开始的表面积
    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<sstream>
    #include<cmath>
    #include<stack>
    #include<cstdlib>
    #include <vector>
    #include<queue>
    using namespace std;
    
    #define ll long long
    #define llu unsigned long long
    #define INF 0x3f3f3f3f
    #define PI acos(-1.0)
    const int maxn =  1e5+5;
    const int  mod = 1e9+7;
    
    int main()
    {
        ll n;
        while(~scanf("%lld",&n))
        {
            ll sum = ((n*n*n)*((n*n*n)-1))/2 - (6*n*n*n - 6*n*n)/2;
            printf("%lld
    ",sum);
        }
    }
  • 相关阅读:
    TextFlow with JavaFX 2
    搞IT的技术人员为什么会如此苦逼
    Spring MVC3.0.5搭建全程
    JetNuke笔记 ( by quqi99 )
    What is the difference between application server and web server?
    Customize Netbeans Platform Splash Screen and About Dialog
    caffe-win10-cifar10
    Ubuntu14.04+caffe+CPU
    win10+caffe+GPU
    Majority Element(169) && Majority Element II(229)
  • 原文地址:https://www.cnblogs.com/smallhester/p/10327466.html
Copyright © 2011-2022 走看看