hdu 1220组合数学】的更多相关文章

两个立方体相交的点数有0 1 2 4 不考虑相交点数的话有C(n,2)个立方对. 而求不超过两个交点的对数,即为用总的减去有四个交点的对数,而四个交点即为同面 四个交点的对数为相同的面的个数为(所有的小立方体 的所有面(6*n*n*n)-外面的6个大面(6*n*n))/2 所以得到 n*n*n*(n*n*n-1)/2-(6*n*n*n-6*n*n)/2 #include<stdio.h> int main() {    int n;    while(scanf("%d",…
传送门: 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 pro…
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): 2260    Accepted Submission(s): 1819 Problem Description Cowl is good at solving math problems…
http://acm.hdu.edu.cn/showproblem.php?pid=1220 一开始的做法是,先暴力算出一个面,就是n * n的面,能有多少对.记作face 然后从上开始算下来,最上一层,face个,然后第二层,有n * n * (up - 1)个. 递推下去,up是在第i层上面有多少个. #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #inc…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1220 问题描述 Cowl擅长解决数学问题. 有一天,一位朋友问他这样一个问题:给你一个边长为N的立方体,它被与其侧面平行的平面切割成N * N * N个单位立方体. 两个单位立方体可能没有共同点或两个共同点或四个共同点. 你的工作是计算有多少对不超过两个公共点的单位立方体.处理到文件的结尾. 输入 会有很多测试用例. 每个测试用例只会在一行中给出一个立方体的边长N. N是正整数(1 <= N <=…
http://acm.hdu.edu.cn/showproblem.php?pid=5106 给定n和r,要求算出[0,r)之间所有n-onebit数的和,n-onebit数是所有数位中1的个数. 对于一个n-bit数,可以根据与R最高不同位的位置分成几类.比如R=100100010,可以分成0xxxxxxxx,1000xxxxx,10010000x三类.x处可任取0或者1.x的个数为n,x中1的个数为k.和分两部分,高于n位的有C(n,k)乘以n位之前的数字,低于n位的部分有C(n-1,k-1…
Time Limit: 2000/1000 MS (Java/Others)   Memory Limit: 131072/131072 K (Java/Others) Problem Description soda has a set S with n integers {1,2,…,n}. A set is called key set if the sum of integers in the set is an even number. He wants to know how man…
题意:一个边长为N的正方体,切割成N*N*N个单位正方体,问有多少对正方体之间有0个,2个公共点. 思路:因为正方体之间出现公共点的情况有0,2,4. 那么直接正面求,肯定不好求,那么先求出有4个公共顶点的对数m. 怎么求呢?通过观察,其实就是外面的一个面没有相邻小正方体,其他都相邻了,那就是总的小正方体的总面数-在表面的面数就可以了 同时,求的是对数,所以最后不要忘了除以2.         公式  (N*N*N*6 - N*N*6)/3          在代码中只是把它化简了 #inclu…
直接凑了个公式带入,没想到直接ac了,至于题解中的期望可加性可以参考概率论相关知识 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> using namespace std; #define for0n for(i=0;i<n;i++) #define w12 whil…
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 commo…