poj 2363 Blocks

Blocks

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7350   Accepted: 3543

Description

Donald wishes to send a gift to his new nephew, Fooey. Donald is a bit of a traditionalist, so he has chosen to send a set of N classic baby blocks. Each block is a cube, 1 inch by 1 inch by 1 inch. Donald wants to stack the blocks together into a rectangular
solid and wrap them all up in brown paper for shipping. How much brown paper does Donald need?

Input

The first line of input contains C, the number of test cases. For each case there is an additional line containing N, the number of blocks to be shipped. N does not exceed 1000.

Output

Your program should produce one line of output per case, giving the minimal area of paper (in square inches) needed to wrap the blocks when they are stacked together.

Sample Input

5
9
10
26
27
100

Sample Output

30
34
82
54
130

题意:已知一个立方体的体积,求这个立方体的最小表面积;

题解:暴力枚举x和y;

#include <iostream>
using namespace std;
int main(){
	int n,t;
	cin>>t;
	while (cin>>n){
		int min=0xffffff;
		for (int x=1;x<=n;x++){
			if (n%x!=0)
				continue;
			for (int y=1;y<=n;y++){
				if (n%y!=0||n%(x*y)!=0)
					continue;
				int z=n/(x*y);
				int s=2*(x*y+x*z+y*z);
				if (min>s)
					min=s;
			}
		}
		cout<<min<<endl;
	}
	return 0;
}
时间: 2024-08-26 12:25:22

poj 2363 Blocks的相关文章

POJ 2363 Blocks(简单题)

[题意简述]:求由小正方体组成的大的长方体的表面积. [分析]:注意边界. // 268K 0Ms #include<iostream> using namespace std; int main() { int C; int t; int l,w;//底面的长和宽 int h;// 立方体的高 int s=0;//表面积 cin>>C; int Min; while(C--) { cin>>t; Min = 0xfffffff; for(int i = 1;i<

POJ 3734 Blocks

                                                         POJ 3734   Blocks Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description Panda has received an assignment of painting a line of blocks. Since Panda is such an

[POJ 3734] Blocks (矩阵快速幂、组合数学)

Blocks Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3997   Accepted: 1775 Description Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of paint

[POJ 1390]Blocks

Description Some of you may have played a game called 'Blocks'. There are n blocks in a row, each box has a color. Here is an example: Gold, Silver, Silver, Silver, Silver, Bronze, Bronze, Bronze, Gold. The corresponding picture will be as shown belo

POJ 1390 Blocks(记忆化搜索+动态规划)

POJ 1390 Blocks 砌块 时限:5000 MS   内存限制:65536K 提交材料共计: 6204   接受: 2563 描述 你们中的一些人可能玩过一个叫做"积木"的游戏.一行有n个块,每个盒子都有一个颜色.这是一个例子:金,银,铜,金.相应的图片如下: 图1如果一些相邻的盒子都是相同的颜色,并且它左边的盒子(如果它存在)和它的右边的盒子(如果它存在)都是其他颜色的,我们称它为"盒子段".有四个盒子段.那就是:金,银,铜,金.片段中分别有1,4,3,

poj 3734 Blocks 【矩阵快速幂】

Blocks Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4529 Accepted: 2044 Description Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting.

POJ 3734 Blocks (矩阵快速幂)

题目链接:http://poj.org/problem?id=3734 <挑战程序设计竞赛>202页.与单纯的用递推式与矩阵快速幂求第N项不同,设染到第i个方块为止,红绿都是偶数的方案数目为a,红绿恰有一个是偶数方案数目为b,红绿都是奇数方案数目为c, 则: a[i+1] = 2 * a[i] + b[i] b[i+1] = 2 * a[i]+2 * b[i]+2 * c[i] c[i+1] = b[i] + 2 * c[i] 之后构建3*3矩阵求解 代码: 1 typedef vector&

poj 1390 Blocks (经典区间dp 方块消除)

Blocks Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4250   Accepted: 1704 Description Some of you may have played a game called 'Blocks'. There are n blocks in a row, each box has a color. Here is an example: Gold, Silver, Silver, Sil

POJ 3734 Blocks(矩阵快速幂加递推)

Blocks Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6133   Accepted: 2931 Description Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of paint