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.
1
2
3
0
16
297
The results will not exceed int type.
Hint
思路:在所有的立方体中任选2个是所有的情况,减去四个公共公共点的情况
#include <iostream>
using namespace std;
int main(){
int n,m;
while(~scanf("%d",&n)){
m = n*n*n*(n*n*n-1)/2 - (6*n*n*n-6*n*n)/2;
printf("%d\n",m);
}
return 0;
}