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. pat1056. Mice and Rice (25)

    1056. Mice and Rice (25) 时间限制 30 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Mice and ...

  2. 使用Fsharp 探索 Dotnet 平台

    Fsharp的交互开发环境使得我们在了解DotNet平台时能够快速的获得需要的反馈. 反馈在任何技艺的磨练过程中必不可少,我认为也是最重要的环节之一.在“一万小时天才理论”中,著名的髓鞘质就是在快速有 ...

  3. vue实现选中列表功能

    <template> <div> <ul v-for="prop in items"> <dt>{{prop.name}}</ ...

  4. Servlet和JavaBean

    1.Servlet简介: Java Servlet 是运行在 Web 服务器或应用服务器上的程序,它是作为来自 Web 浏览器或其他 HTTP 客户端的请求和 HTTP 服务器上的数据库或应用程序之间 ...

  5. HDU 1010 Tempter of the Bone 骨头诱惑(DFS+剪枝)

    题意: 必须在第t秒走到格子D上,S为起点,D为终点,点就是可以走,X就是墙. 思路: 将迷宫外围四面都筑墙‘X’.深度搜索+奇偶剪枝,再加一个剪枝“无法在指定时间内到达”. #include < ...

  6. js高级笔录

    1.类型转换①转换成字符串toString() ⅰBoolean 值.数字和字符串的原始值的有趣之处在于它们是伪对象,这意味着它们实际上具有属性和方法. var sColor = "red& ...

  7. 手把手教你用Docker部署一个MongoDB集群

    MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中最像关系数据库的.支持类似于面向对象的查询语言,几乎可以实现类似关系数据库单表查询的绝大部分功能,而且还支持对数据建立索引 ...

  8. POJ-1459 Power Network---最大流

    题目链接: https://cn.vjudge.net/problem/POJ-1459 题目大意: 简单的说下题意(按输入输出来讲,前面的描述一堆的rubbish,还用来误导人),给你n个点,其中有 ...

  9. 3219: 求最高同学位置—C语言版

    3219: 求最高同学位置—C语言版 时间限制: 1 Sec  内存限制: 128 MB提交: 207  解决: 115[提交][状态][讨论版][命题人:smallgyy] 题目描述 设一维数组存放 ...

  10. 《GPU高性能编程CUDA实战中文》中第四章的julia实验

    在整个过程中出现了各种问题,我先将我调试好的真个项目打包,提供下载. /* * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. ...