hdu1220
来源:互联网 发布:淘宝一分钱虚拟商品 编辑:程序博客网 时间:2024/05/03 05:54
给出一个n的立方体。
然后你去拆成体积为1的立方体。
对于拆出来的任意两个立方体。
两个立方体之间的交点可能有 0,1,2,4
只要所有的减去4的就是答案。
四的 一列由n-1个,每个面有 N^2,总共上左下三个面
#include <iostream>#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <deque>#include <utility>#include <complex>#include <string>#include <vector>#include <bitset>#include <algorithm>using namespace std;const int maxn=35;int f[maxn]; #define cal(x) (x)*(x)*(x)*((x)*(x)*(x)-1)/2-(x)*(x)*(x-1)*3int main(){ int n; while(scanf("%d",&n)!=EOF) { printf("%d\n",cal(n)); } return 0;}
也可以细分出来计算四的对数 先是内层接触的(n-2)^2*6 然后是考虑以单面(n-1)*(n)*2*6 减去外层12条边里面的数(n-1)*12 加上内层的里面的数值f(n-2)
#include <iostream>#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <deque>#include <utility>#include <complex>#include <string>#include <vector>#include <bitset>#include <algorithm>using namespace std;const int maxn=35;int f[maxn];#define floor(x) (x)*(x-1)*2*6#define inner(x) (x-2)*(x-2)*6#define over(x) (x-1)*12#define all(x) (x)*(x)*(x)*((x)*(x)*(x)-1)/2int cal(int n){ return (inner(n)+floor(n)-over(n)+f[n-2]);}int main(){ f[0]=0; f[1]=0; for(int i=2;i<=30;i++) f[i]=cal(i); int n; while(scanf("%d",&n)!=EOF) { int ans=0; if(n>1) ans=all(n)-f[n]; printf("%d\n",ans); } return 0;}
0 0
- HDU1220
- hdu1220
- HDU1220
- HDU1220 Cube
- hdu1220 Cube
- HDU1220--Cube HDU(93)
- 【数学.前左上计数法】【HDU1220】Cube
- hdu1220组合数学,求公共点小于2的面数对
- 线程局部存储(TLS)
- git 操作记录
- bootargs--内核启动参数介绍
- Oracle数据库操作中锁表查询以及解锁和kill进程操作脚本
- 03_js中的继承
- hdu1220
- 海选女主角
- (LeetCode)杨辉三角形Pascal's Triangle
- 10. Browser 对象 - Location 对象(2)
- VS Addin插件基本开发入门
- SQLServer2005 localhost和127.0.0.1无法连接数据库以及python的pymssql连接错误20009
- 两数组最短距离
- D - Machine Schedule
- MD5算法原理(详细)