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<=t;i++)
		{
			if(t%i==0)
			{
				h = t/i;
				for(int j = 1;j<=i;j++)
				{

					if(i%j == 0)
					{
						l = j;
						w = i/j;
						s = (h*l+h*w+l*w)*2;
						if(s<Min)
							Min = s;
					}
				}
			}
		}
		cout<<Min<<endl;
	}
	return 0;
}
时间: 2024-08-30 03:09:49

POJ 2363 Blocks(简单题)的相关文章

POJ 3094 Quicksum(简单题)

[题意简述]:题意很简单.看例子就能理解 [分析]:略.字符串的读取操作. // 200K 0Ms #include<iostream> using namespace std; int main() { char a[256]; while(1) { int sum = 0; gets(a); if(strcmp(a,"#")==0) break; int len = strlen(a); for(int i = 0;i<len;i++) { if(a[i] ==

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.

POJ 2393 贪心 简单题

有一家生产酸奶的公司,连续n周,每周需要出货numi的单位,已经知道每一周生产单位酸奶的价格ci,并且,酸奶可以提前生产,但是存储费用是一周一单位s费用,问最少的花费. 对于要出货的酸奶,要不这一周生产,要不提前生产. 什么时候采用什么生产方式呢? 若第i周的货提前生产的话,假设在j周生产,则费用为(i-j)*s+c[j] 若c[i]>(i-j)*s+c[j],则更新c[i]=(i-j)*s+c[j] 更新要O(n^2)? 可以证明,最优的生产方式是,要不在这一周生产,要不在上一周生产(这里的上

poj 3270 Cow Sorting 置换群 简单题

假设初始状态为 a:2 3 1 5 4 6 则目标状态为 b:1 2 3 4 5 6且下标为初始状态中的3 1 2 4 5 6(a[3],a[1]...) 将置换群写成循环的形式 (2,3,1),(5,4),6就不用移动了. 移动方式2种 1:选循环内最小的数和其他len-1个数交换 2:选整个序列最小的数和循环内最小的数交换,转到1,再换回来. #include<cstdio> #include<queue> #include<algorithm> #include&

poj 3112 Digital Biochemist Circuit(简单题)

题目链接:http://poj.org/problem?id=3112 Digital Biochemist Circuit Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 876   Accepted: 375 Description A digital biochemist circuit (DBC) is a device composed of a set of processing nodes. Each pro

POJ Frogs&#39; Neighborhood havel-hakimi定理 (简单题)

Frogs' Neighborhood Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 8263   Accepted: 3504   Special Judge Description 未名湖附近共有N个大小湖泊L1, L2, ..., Ln(其中包括未名湖),每个湖泊Li里住着一只青蛙Fi(1 ≤ i ≤ N).如果湖泊Li和Lj之间有水路相连,则青蛙Fi和Fj互称为邻居.现在已知每只青蛙的邻居数目x1, x2, ..

POJ 2405 Beavergnaw (计算几何-简单题)

Beavergnaw Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6203   Accepted: 4089 Description When chomping a tree the beaver cuts a very specific shape out of the tree trunk. What is left in the tree trunk looks like two frustums of a co

POJ 2909 Goldbach&#39;s Conjecture(简单题)

[题意简述]:输入一个数,输出有几对素数对可以使他们的和正好等于这个数 [分析]:暴力打表,再暴力循环求解 //268K 125Ms #include<iostream> using namespace std; #define N 35000 // 2^15 bool isprime[N]; int prime[N],nprime;//prime[N]用来存储素数,nprime是此时一共有多少素数 void doprime(int n) { int i,j; nprime = 1; mems

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive