Cube

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

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.

 

题解:好菜,自己竟然没推出来。。。

总对数n^3*(n^3-1)/2;

点数为4的对数:一行有n-1对,一个面有总共n*n行,三个面面要乘以3;

总的减去4的就是<=2的了;

代码:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define PI(x) printf("%d",x)
#define P_ printf(" ")
const int INF=0x3f3f3f3f;
int main(){
int n;
while(~scanf("%d",&n)){
printf("%d\n",n*n*n*(n*n*n-)/-n*n*(n-)*);
}
return ;
}

Cube(规律)的更多相关文章

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

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

  2. Cube 找规律

    这道题我们经过简单的推测便可得知3个之前特判,四个之后就成为了一般状况,就是我们每侧都是走整个整个的|_|之后零的走|||. 考试的时候包括平时做题,许多正确的感性比理性证明要强得多. #includ ...

  3. UVA 253 Cube painting(暴力打表)

    Cube painting Problem Description: We have a machine for painting cubes. It is supplied with three d ...

  4. Break the Chocolate(规律)

    Break the Chocolate Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  5. [补档]Cube

    Cube 题目 给你一个n×m的棋盘,有一个1×1×2的长方体竖直放在(1,1)上,你可以将其在棋盘上滚动,你的目标是让其竖直放在(n,m)上,问至少需要多少次操作.(放倒.竖直.翻滚) INPUT ...

  6. HDU 多校对抗第三场 L Visual Cube

    Problem L. Visual Cube Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java ...

  7. SQL SEVER (ROLLUP与CUBE,ROW_NUMBER())使用方法

    1.建立测试专用数据: if object_id('TESTDB') is not null drop table TESTDB ), B INT) insert into TESTDB union ...

  8. hdu1452 Happy 2004(规律+因子和+积性函数)

    Happy 2004 题意:s为2004^x的因子和,求s%29.     (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...

  9. Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

    传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...

随机推荐

  1. 百度地图V2.0实践项目开发工具类bmap.util.js V1.4

    /** * 百度地图使用工具类-v2.0(大眾版) * * @author boonya * @date 2013-7-7 * @address Chengdu,Sichuan,China * @em ...

  2. hdu 5620 KK's Steel(推理)

    Problem Description Our lovely KK has a difficult mathematical problem:he has a N(1≤N≤1018) meters s ...

  3. ps怎样选取自己想要的图片部分(二)

    上篇文章我们介绍了怎样选取所要的图形.但往往我们实际做项目的时候须要创建一个圆形图标或者椭圆形图标,这样会使得我们的图标相比矩形图标更加美观一些. 那么怎样将一个矩形图标改成圆形图标呢? 首先我们须要 ...

  4. Hadoop书籍下载链接

    Hadoop书籍推荐1:Hadoop实战(结合经典案例全面讲解hadoop整个技术体系)http://www.db2china.net/club/thread-25148-1-1.html2:Hado ...

  5. 【Trie】【HDU1247】【Hat’s Wordsfd2】

    题目大意: hat's word 的定义是字典中 恰好由另外两个单词连接起来的单词 给你一本字典,问有多少个hat's word,(字典按字典序给出) 单词数50000.. 初步思路: 单词分为前缀单 ...

  6. JavaScript检测之basevalidate.js

    上篇文章「JavaScript检测原始值.引用值.属性」中涉及了大量有用的代码范例,为了让大家更方便的使用这些代码,博主特意把这些代码重新整理并托管到 GitHub,项目地址是:https://git ...

  7. UVA 1610 Party Games

    题意: 给出一系列字符串,构造出一个字符串大于等于其中的一半,小于另一半. 分析: 取大小为中间的两个a,b(a<b).实际上就是找出第一个小于b的同时大于等于a的字符串,直接构造即可. 代码: ...

  8. hdu2222Keywords Search

    Problem Description In the modern time, Search engine came into the life of everybody like Google, B ...

  9. 关于ECharts Java类库的一个jquery插件

    在项目中开发图表功能时用到了Echars和一个关于Echars的java类库(http://git.oschina.net/free/ECharts).这个类库主要目的是方便在Java中构造EChar ...

  10. C++ strcpy实现

    char * strcpy(char * strDest,const char * strSrc) { if ((NULL==strDest) || (NULL==strSrc))  throw &q ...