首页 > ACM题库 > HDU-杭电 > hdu 2130 Count the cuboids-计算几何[解题报告]C++
2013
12-29

hdu 2130 Count the cuboids-计算几何[解题报告]C++

Count the cuboids

问题描述 :

Look up the picture A , the big wood is cut into many small ones. As we know, a cuboid has three attributes: Length, Width and Height. In the picture B, C, D, there are different. The problem is so easy that you just need to count the kinds of the cuboids which can be cut from the big one. When we cut the big one into so many small one, we give every one a number to mark which is 1×1×1. Look at the picture B and C, they have the same length, width and height, but the marking numbers they have are different from each other, so B is different from C. B and D have the different attributes (any one attribute of the length, width and height is different), so they are also different.

输入:

Many data cases come. In each case, there are three positive integers L, W, H, which are the length, the width and the height of the LWH. When L, W and H are all -1, the input is over, and you haven’t to handle them.

输出:

Many data cases come. In each case, there are three positive integers L, W, H, which are the length, the width and the height of the LWH. When L, W and H are all -1, the input is over, and you haven’t to handle them.

样例输入:

5 3 4
2 2 2
1 1 2
-1 -1 -1

样例输出:

900
27
3

题目大意:给一个W*H*L的长方体,问能把这个长方体切一个长方体出来有多少种切法,不知道怎么说,大概就这意思吧。
这题目很贱,说是结果不超出int 32,还弄了个过程超int 32的。
貌似HDU向来都喜欢做这种贱B的事情!
直接从直线上来看,对于直线上的n个点,我们可以取到n*(n-1)/2 条不同的线段
那么三维就是每一维的线段数的成绩
题目说的是长度,所以长度为n的 有n+1个点。!!
我的代码:

#include <stdio.h>
int main ()
{
__int64 a,b,c,n;
while (scanf("%I64d %I64d %I64d",&a,&b,&c)!=EOF)
{
   if (a==-1 && b==-1 && c==-1) return 0;
   n=a*(a+1)*b*(b+1)*c*(c+1)/8;
   printf ("%I64d\n",n);
}
return 0;
}
用int也行:
#include <stdio.h>
int main ()
{
int a,b,c,n;
while (scanf("%d %d %d",&a,&b,&c)!=EOF)
{
   if (a==-1 && b==-1 && c==-1) return 0;
   n=0.125*a*(a+1)*b*(b+1)*c*(c+1);
   printf ("%d\n",n);
}
return 0;
}

 


  1. 因为是要把从字符串s的start位到当前位在hash中重置,修改提交后能accept,但是不修改居然也能accept

  2. [email protected]

  3. 这个方法是错的,不信你试试:
    20 5
    1 A:9
    1 A:9
    1 A:9
    1 A:6
    1 A:4
    正确答案应该是19,这个答案是18