Hust oj 1241 Blocks(暴力)

原创 2016年08月29日 23:50:32
Blocks
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 74(29 users) Total Accepted: 46(27 users) Rating: Special Judge: No
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
纯暴力
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int t;

int main()
{
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int Min = 0x3f3f3f;
        for(int i=1;i<=1000;i++)
        {
            if(i > n) break;
            for(int j=1;j<=1000;j++)
            {
                if(i * j > n) break;
                for(int k=1;k<=1000;k++)
                {
                    if(i * j * k > n) break;
                    if(i * j * k == n && (2 * (i * j + i * k + j * k) < Min))
                        Min = 2 * (i * j + i * k + j * k);
                }
            }
        }
        printf("%d\n",Min);
    }
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

hrbust 1241 Blocks【暴力枚举+简单优化】

Blocks Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 77(30 user...

Hust oj 1990 函数F(x)(暴力)

函数F(x) Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 260(114 users) Total Acce...
  • Sara_YF
  • Sara_YF
  • 2016年05月29日 13:33
  • 187

Hust oj 1151 追求(暴力)

追求 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 236(61 users) ...
  • Sara_YF
  • Sara_YF
  • 2016年08月28日 23:25
  • 211

Hust oj 1280 回文数(暴力枚举)

回文数 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 161(52 users)...
  • Sara_YF
  • Sara_YF
  • 2016年07月27日 23:23
  • 246

hust 1586 数字排列(暴力 全排列)

1586 - 数字排列 Time Limit: 1s Memory Limit: 128MB Submissions: 78 Solved: 28 DESCRIPTION ...

HUST 1588 辗转数对【Gcd拓展应用+思维+暴力枚举】

1588 - 辗转数对 Time Limit: 1s Memory Limit: 128MB Submissions: 153 Solved: 26 DESCRIPTIO...

HUST-1601 - Shepherd 暴力

1601 - Shepherd时间限制:2秒 内存限制:64兆 511 次提交 84 次通过 题目描述 Hehe keeps a flock of sheep, numbered from 1 ...

HUST 1586 数字排列【暴力枚举】水题

1586 - 数字排列 Time Limit: 1s Memory Limit: 128MB Submissions: 78 Solved: 28 DESCRIPTION...

CSU OJ:1241 数字序列(并查集+思维)

1241: 数字序列 Submit Page     Summary    Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitt...
  • zugofn
  • zugofn
  • 2017年04月12日 22:06
  • 322

Hust oj 1953 RSA验证(快速幂)

RSA验证 Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 38(24 users...
  • Sara_YF
  • Sara_YF
  • 2016年09月15日 21:56
  • 194
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Hust oj 1241 Blocks(暴力)
举报原因:
原因补充:

(最多只允许输入30个字)