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.

InputThere 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). 
OutputFor 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 The results will not exceed int type.

Hint

Hint

题意:长度为n的立方体切为n*n*n个长度为1的立方体,求相邻的点小于等于两个的个数
题解:相反考虑,排列组合,结合切好后的总表面积和一开始的表面积
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<cmath>
#include<stack>
#include<cstdlib>
#include <vector>
#include<queue>
using namespace std; #define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
const int maxn = 1e5+;
const int mod = 1e9+; int main()
{
ll n;
while(~scanf("%lld",&n))
{
ll sum = ((n*n*n)*((n*n*n)-))/ - (*n*n*n - *n*n)/;
printf("%lld\n",sum);
}
}

Cube HDU - 1220(思维)的更多相关文章

  1. B - Cube HDU - 1220 (数学计数)

    题意:一个边长为N的正方体,切割成N*N*N个单位正方体,问有多少对正方体之间有0个,2个公共点. 思路:因为正方体之间出现公共点的情况有0,2,4. 那么直接正面求,肯定不好求,那么先求出有4个公共 ...

  2. HDU 2588 思维 容斥

    求满足$1<=X<=N ,(X,N)>=M$的个数,其中$N, M (2<=N<=1000000000, 1<=M<=N)$. 首先,假定$(x, n)=m$ ...

  3. HDU 1431 思维 基础数论

    找范围内回文素数,最大到1e8,我就是要枚举回文串,再判素数,然后因为这种弱智思路死磕了很久题目. /** @Date : 2017-09-08 15:24:43 * @FileName: HDU 1 ...

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

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

  5. HDU 1220 B - Cube

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

  6. 题解报告:hdu 1220 Cube

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

  7. hdu 1220 容斥

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

  8. hdu 4883 思维题

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4883 TIANKENG’s restaurant Time Limit: 2000/1000 MS (Ja ...

  9. hdu 5014 思维题/推理

    http://acm.hdu.edu.cn/showproblem.php?pid=5014 从小数開始模拟找方法规律,然后推广,尤其敢猜敢尝试,错了一种思路继续猜-----这是一种非常重要的方法啊 ...

随机推荐

  1. varnish与squid的比较

    生产环境中尝试使用varnish替代squid的主要原因: 1. squid不支持多核cpu, 生产环境中大多使用Dell R610系列,这种类型机器配置为2个4核双线程cpu, 操作系统识别为16个 ...

  2. 如何在oracle中导入导出dmp数据库文件

    Oracle数据导入导出imp/exp就相当于oracle数据还原与备份.exp命令可以把数据从远程数据库服务器导出到本地的dmp文件,imp命令可以把dmp文件从本地导入到远处的数据库服务器中.利用 ...

  3. MySQL分库分表的技巧

    分表是分散数据库压力的好方法. 分表,最直白的意思,就是将一个表结构分为多个表,然后,可以再同一个库里,也可以放到不同的库. 当然,首先要知道什么情况下,才需要分表.个人觉得单表记录条数达到百万到千万 ...

  4. UITableViewCellStyle 四种样式

    四种样式如下:

  5. Mavlink 协议 理解

    来源:blog.csdn.net/super_mice/article/details/44836585 之前看了mavlink协议,网上关于mavlink的资料不多.本文大概总结了下对mavlink ...

  6. java集合杂谈

    一:java集合框架如下图所示: 大致说明:看上面的框架图,先抓住它的主干,即Collection和Map. 1.Collection是一个接口,是高度抽象出来的集合,它包含了集合的基本操作和属性.C ...

  7. 如何查看与显示oracle表的分区信息

    显示分区表信息 显示数据库所有分区表的信息:DBA_PART_TABLES 显示当前用户可访问的所有分区表信息:ALL_PART_TABLES 显示当前用户所有分区表的信息:USER_PART_TAB ...

  8. IDA逆向:结构体的逆向

    源代码: int _tmain(int argc, _TCHAR* argv[]) { struct v1 { int a; short b; char c; int d; double e; }; ...

  9. pta 编程题15 列出连通集

    其它pta数据结构编程题请参见:pta 题目 题目要求分别以深度优先搜索和广度优先搜索输出图的连通集. 广度优先搜索要用到队列,先回顾一下循环队列: struct QNode { int* Data; ...

  10. raspberrypi&linux

    Raspberrypi&linux 2018-01-23 19:54:01 Let's go!