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;
}
本文介绍了一个数学问题的解决方法,该问题是计算给定边长为N的大立方体被切割成N*N*N个小立方体后,有多少对小立方体最多只共有点的情况。通过组合数学的方法减去所有共面的小立方体对,最终得出答案。
1012

被折叠的 条评论
为什么被折叠?



