Cube
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 972    Accepted Submission(s): 775

Problem Description
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.

 

Input
There 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).
 

Output
For 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
Hint

Hint

The results will not exceed int type.

 

Author
Gao Bo
 

Source
 

Recommend
Ignatius.L
 

给你一个正方体,切割成单位体积的小正方体,求所有公共顶点数<=2的小正方体的对数。公共点的数目只可能有:0,1,2,4.很明显我们用总的对数减掉有四个公共点的对数就可以了。
总的公共点对数:n^3*(n^3-1)/2(一共有
n^3块小方块,从中选出2块
)(只有两个小方块之间才存在公共点,我们从所有的小方块中任意选出两个,自然就确定了这两个小方块的公共点的对数,从所有小方块中任意选取两个,总得选取方法数就是所有种类对数数目的总和!)
公共点为4的对数:一列有n-1对(n个小方块,相邻的两个为一对符合要求),一个面的共有 n^2列,底面和左面,前面三个方向相同,同理可得,故总数为:3*n^2(n-1)
所以结果为:n^3 * (n^3-1) - 3*n^2(n-1)

HDOJ 1220 Cube的更多相关文章

  1. HDU 1220 Cube(数学,找规律)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1220 Cube Time Limit: 2000/1000 MS (Java/Others)    M ...

  2. 题解报告:hdu 1220 Cube

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1220 问题描述 Cowl擅长解决数学问题. 有一天,一位朋友问他这样一个问题:给你一个边长为N的立方体 ...

  3. hdu 1220 容斥

    http://acm.hdu.edu.cn/showproblem.php?pid=1220 Cube Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  4. 2018年暑假ACM个人训练题7 题解报告

    A:HDU 1060 Leftmost Digit(求N^N的第一位数字 log10的巧妙使用) B:(还需要研究一下.....) C:HDU 1071 The area(求三个点确定的抛物线的面积, ...

  5. HDOJ 3547 DIY Cube 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3547 题目大意:求用$C$种颜色给立方体的8个顶点染色的本质不同的方法.两种方法本质不同即不能通过旋转 ...

  6. 【HDOJ】4801 Pocket Cube 的几种解法和优化

    1. 题目描述给定一个$2 \times 2 \times 2$的魔方,当某个面上的4个小块颜色均相同时,称这个面为complete.求对这个魔方进行$n \in [1,7]$次旋转(沿某个面顺时针或 ...

  7. Cube HDU - 1220(思维)

    Cowl is good at solving math problems. One day a friend asked him such a question: You are given a c ...

  8. HDU 1220 B - Cube

    http://acm.hdu.edu.cn/showproblem.php?pid=1220 一开始的做法是,先暴力算出一个面,就是n * n的面,能有多少对.记作face 然后从上开始算下来,最上一 ...

  9. 【HDOJ】3584 Cube

    三位树状数组. /* 3584 */ #include <iostream> #include <string> #include <map> #include & ...

随机推荐

  1. STM32F0xx_EXIT中断配置详细过程

    Ⅰ.概述 EXIT外部中断在使用到按键或者开关控制等应用中比较常见,低功耗中断唤醒也是很常见的一种.因此,EXIT在实际项目开发中也是比较常见的一种. STM32F0中外部中断EXIT属于中断和事件的 ...

  2. Java入门到精通——工具篇之Maven概述

    为接手gxpt准备已经快一个月了从SSH2-->EJB-->环境搭建-->Maven的构建.下面就带领大家初始Maven 一.什么是Maven. Maven是一个垮平台的项目管理工具 ...

  3. android Init 相关分析

    Init.c主要工作 1. 初始化属性(包括建立/dev./proc等目录.初始化属性.log.执行init.rc等初始化文件中的action等). 2. 解析配置文件的命令(主要是init.rc文件 ...

  4. 【转】VNC配置

    配置VNC服务参数文件 编辑vncservers文件追加如下 #vi /etc/sysconfig/vncsevers VNCSERVERS="1:root" VNCSERVERA ...

  5. mysql数据库编码设置成utf-8,避免出现乱码

    设置默认编码为utf8:set names utf8;设置数据库db_name默认为utf8:ALTER DATABASE `db_name` DEFAULT CHARACTER SET utf8 C ...

  6. Redis 客户端配置及示例

    一.redis自定义配置节点 <configSections> <section name ="RedisConfig" type="Amy.Toolk ...

  7. HTML a 标签 下载 apk 文件

    代码:   <a href="http://www.abc2016.com/phone_Client/shouji.apk" class="download_inp ...

  8. 升级ubuntu内核

    ubuntu12.04内核为 linux-image-3.5.0-23-generic 要升级为 linux-image-3.2.0-57-generic 使用apt-get install linu ...

  9. SpringMVC核心类DispatcherServlet

    配置DispatcherServlet 要使用SpringMVC,必须在web.xml中配置好这个DispatcherServlet类 <!-- spring框架必须定义ContextLoade ...

  10. hibernate tool连接oracle生成pojo和xml文件无法查询表解决办法

    需要在hibernate的配置文件中增加 <property name="hibernate.default_schema">[username]</proper ...