传送门:

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. 简单实现 ArrayList

    java中提供了多个集合框架 其中就有ArrayList  下面简单的实现一下 只写了添加,获取长度和根据下标获取元素的方法 public class MyArrayList { //定义一个obje ...

  2. pat1011. World Cup Betting (20)

    1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...

  3. OpenLayers 案例一

    序 OpenLayers 是一个专为Web GIS 客户端开发提供的JavaScript 类库包,用于实现标准格式发布的地图数据访问. 例子 <!doctype html> <htm ...

  4. SpringBoot集成JWT 实现接口权限认证

    JWT介绍 Json web token (JWT), 是为了在网络应用环境间传递声明而执行的一种基于JSON的开放标准((RFC 7519).该token被设计为紧凑且安全的, 特别适用于分布式站点 ...

  5. 对key中有数字的字典进行排序

    word_cloud = []cc = [{"c58":341,"c59":525,"c56":507,"c57":34 ...

  6. Halcon学习笔记——机器视觉应用工程开发思路及相机标定

    机器视觉应用工程开发思路 机器视觉应用工程主要可划分为两大部分,硬件部分和软件部分. 1.硬件部分,硬件的选型至关重要,决定了后续工作是否可以正常开展,其中关键硬件部分包括:光源,相机以及镜头. 2. ...

  7. MarkDown 语言简单使用

    # Markdown file ![alt img is error](http://cdn2.jianshu.io/assets/web/logo-58fd04f6f0de908401aa561cd ...

  8. PAT 1024 Palindromic Number

    #include <cstdio> #include <iostream> #include <cstdlib> #include <algorithm> ...

  9. express 请求跨域后端解决方法CORS

    CORS全称Cross-Origin Resource Sharing,是HTML5规范定义的如何跨域访问资源. Origin表示本域,也就是浏览器当前页面的域.当JavaScript向外域(如sin ...

  10. 【css基础】html图片右上角加上删除按钮

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...