传送门:

http://acm.hdu.edu.cn/showproblem.php?pid=1220

Cube

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2627    Accepted Submission(s): 2064

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
 
    分析:
    题意:
    有一个N*N*N的立方体,
    将其分成1*1*1的单位立方体,
    任意两个立方体的交点个数为0,1,2,4个,
    现在要求的是小于等于2个交点的对数有多少对。
    思路:
    总的对数:n*n*n的立方体可以分成n*n*n个单位立方体,
    所以一共有C(n*n*n,2)对 (即:n^3*(n^3-1)/2)。
    公共点为4的对数:一列有n-1对(n个小方块,相邻的两个为一对)
    。一个面的共有 n^2列。底面,左面,前面三个方向相同。
    故总数为:3*n^2*(n-1)。
code:
#include <stdio.h>
#include <string.h>
#define max_v 35
int main()
{
int n;
while(~scanf("%d",&n))
{
int result=n*n*n*(n*n*n-)/-*n*n*(n-);
printf("%d\n",result);
}
return ;
}

HDU 1220 Cube(数学,找规律)的更多相关文章

  1. HDU 5914 Triangle 数学找规律

    Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...

  2. # E. Mahmoud and Ehab and the xor-MST dp/数学+找规律+xor

    E. Mahmoud and Ehab and the xor-MST dp/数学/找规律 题意 给出一个完全图的阶数n(1e18),点由0---n-1编号,边的权则为编号间的异或,问最小生成树是多少 ...

  3. HDU 4861 Couple doubi(找规律|费马定理)

    Couple doubi Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  4. hdu 2604 Queuing dp找规律 然后矩阵快速幂。坑!!

    http://acm.hdu.edu.cn/showproblem.php?pid=2604 这题居然O(9 * L)的dp过不了,TLE,  更重要的是找出规律后,O(n)递推也过不了,TLE,一定 ...

  5. hdu 3951 - Coin Game(找规律)

    这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...

  6. HDU 5703 Desert (找规律)

    题意:一杯水有n的容量,问有多少种方法可以喝完. 析:找规律,找出前几个就发现规律了,就是2的多少次幂. 代码如下: #include <cstdio> #include <stri ...

  7. hdu 4952 Number Transformation (找规律)

    题目链接 题意:给你个x,k次操作,对于第i次操作是:要找个nx,使得nx是>=x的最小值,且能整除i,求k次操作后的数 分析: 经过打表找规律,会发现最后的x/i,这个倍数会趋于一个固定的值, ...

  8. hdu 5241 Friends(找规律?)

    Friends Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total S ...

  9. HDU 4279 Number(找规律)

    Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

随机推荐

  1. spring 3.0 @ResponseBody注解返回中文问号乱码解决办法

    前几天给公司做项目,很久没接触java项目的我,遇到了一个问题,就是我在利用异步到控制器中查询,然后返回jaon字符串到前台,字符串中包含中文,于是我直接用了@ResponseBody注解,来返回到前 ...

  2. WPF 窗体在Alt+Tab中隐藏

    问题: 近段时间由于项目上的需求,需要在WPF中使用COM组件,并且由于软件界面设计等等原因,需要将部分控件显示在COM组件之上,由于WindowsFormsHost的一些原因,导致继承在WPF中的W ...

  3. BJFU 1551 ——delightful world——————【暴搜】

    delightful world 时间限制(C/C++):20000MS/30000MS          运行内存限制:65536KByte总提交:33            测试通过:10 描述 ...

  4. 统一latext在vsc的markdown+math和有道云笔记里的出发方式

    起因 前段时间在有道云笔记上写笔记,里面使用latex来记录数学符号,有道云的latex行内触发模式为 `$ latex $`, 之后我在visual studio code里面使用markdown+ ...

  5. indexOf.substr,substring,charAt的区别

    var a = "asdfghjkl" alert(a.substr(1, 3));        //  从下标为1开始,往右数3个长度的数, 显示 sdf; alert(a.s ...

  6. 搭建一个最简单的node服务器

    搭建一个最简单的node服务器 1.创建一个Http服务并监听8888端口 2.使用url模块 获取请求的路由和请求参数 var http = require('http'); var url = r ...

  7. 编程进阶:Java小白的序列化Serializable接口

    在之前的学习过程中,我们知道了如何使用FileInputStream输入流和FileOutputStream输出流编写程序读写文件. 下面我们来学习一下如何使用序列化和反序列化读写文件. 一.序列化 ...

  8. 分布式环境Tomcat多节点集群下共享目录配置,tomcat虚拟目录+nfs

    我们可能有这种场景: 集群环境下,多个web容器需要请求一个共享目录下的文件,比如保存图片或者录音文件,任意一个节点保存后其他节点需要及时获取,此时就需要目录进行同步了,否则Nginx负载到任意一个节 ...

  9. 洛谷P3177 [HAOI2015]树上染色(树上背包)

    题意 题目链接 Sol 比较套路吧,设\(f[i][j]\)表示以\(i\)为根的子树中选了\(j\)个黑点对答案的贡献 然后考虑每条边的贡献,边的两边的答案都是可以算出来的 转移的时候背包一下. # ...

  10. Web前端面试指导(九):盒子模型你是怎么理解的?

    问题分析 这道题问得比较宽泛,一定要找准切入点,如果切入点找不准,很容易乱答,甚至答偏,所以找准切入点是非常的重要的. 解答思路 1)盒子模型有两种,W3C和IE盒子模型 (1)W3C定义的盒子模型包 ...