CSUFT 1004 This is Halloween: Saving Money

1004: This is Halloween: Saving Money

Time Limit: 1 Sec    Memory Limit: 128 MB
Submit: 11    Solved: 2

Description

The Mayor of Halloween Town was always concerned about saving money. When the Pumpkin King, Jack Skelington decided to try his hand at stealing Christmas again, the mayor began trying to cut corners wherever he could to afford it. They were in a recession, after all! When the great Jack commanded him to order enough wrapping paper for all the presents, the Mayor wanted to make sure he would only the absolute minimum amount. In order to do that, he has asked you, the local computer ghoul to write a problem to calculate the amount of wrapping paper that each of the different types of gifts would take. Thankfully for you, all of the gifts are able to fit in different sizes of rectangular boxes (The vampire trio, who is in charge of presents this year, got their start in manufacturing things while interns at Ikea). Each present can be represented by a name, and the three dimensions of the boxa,b,c(0 < a <= b <= c) in frightometers.

The procedure for wrapping the gift is first, a large sheet of wrapping paper is laid on a flat surface. Then, the box is placed on the wrapping paper with one of its 'bc' faces resting on the wrapping paper. The wrapping paper is folded around the four 'c' edges and the excess is cut off, leaving a 3 frightometer wide overlap on one of the 'ac' faces (shown shaded in the figure). At this point, the wrapping paper has the form of a long rectangular tube.

Now more wrapping paper is cut off at the two ends of the tube. It is cut flush with the 'a' edges. Along the 'b' edges, rectangular flaps remain. These rectangular flaps are cut so that when they are folded along the 'b' edges, they cover the two 'ab' faces with a 3 frightometer wide overlap (overlapping areas shown shaded in the figure). The excess paper can be recycled (The Shadow on the Moon at night is an accomplished paper maker!), so that isn't to be taken into account. Calculate the amount of paper, in square frightometers that each box needs in order to be properly wrapped.

Input

Input will begin with a single line containing a single integer,n > 0, wherenis the number types of boxes you need to process. The followingnlines start with the name of a product, in single quotes followed by three integers,a,bandcwhich represent the three dimensions of the package, as illustrated in the picture above. Following the dimensions, a number of significant digits to include in the answer. The number of significant digits will never be greater than the number of digits in the answer. None of the dimensions will be greater than 10,000.

Output

Output will consist ofnlines of the form:"The Present <Present Name> requires <total paper area> square frightometers of paper to wrap"

Sample Input

5
'Kingdom Hearts III: When will it ever come out?' 1 2 3 1
'Killer Bunnies' 7 14 21 2
'Living head of Joseph Mengele' 34 81 101 1
'Barney and Friends: The complete Series' 1 7 11 3
'Abba: Greatest Hits' 45 78 650 5

Sample Output

The Present Kingdom Hearts III: When will it ever come out? requires 40 square frightometers of paper to wrap
The Present Killer Bunnies requires 1200 square frightometers of paper to wrap
The Present Living head of Joseph Mengele requires 20000 square frightometers of paper to wrap
The Present Barney and Friends: The complete Series requires 265 square frightometers of paper to wrap
The Present Abba: Greatest Hits requires 169330 square frightometers of paper to wrap

HINT

 

Source

 

 
此题OJ还有点问题,还是等阳哥来搞改数据吧,原题是LA5745
题意理解:
包装礼品盒,如图的地方加 3 米宽的带子,求最少要多少布料,只保留 d 为有效数字。
 
#include <bits/stdc++.h>
using namespace std;
 
int num[1000];
 
int main()
{
    //freopen("test.in","r",stdin);
    //freopen("out.txt","w",stdout);
    int cases;
    scanf("%d",&cases);
    while(cases--)
    {
 
        char s[10000],t[10000];
        memset(s,'\0',sizeof(s));
        long long a,b,c,d;
        while(1)
        {
            scanf("%s",t);
            strcat(s," ");
            strcat(s,t);
            if(s[strlen(s)-1]=='\'')
                break;
        }
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        //   printf("%s\n",s);
        //   printf("%d %d %d %d\n",a,b,c,d);
 
        long long ans = 2*(a*b+a*c+b*c) + 6*b + 3*c;
       // printf("%d\n",ans);
 
        int k = 0;
        while(ans)
        {
            num[k] = ans % 10;
            ans = ans / 10;
            k++;
        }
 
        int pos = k - d;
 
        long long _ans = 0;
        for(int i=pos; i<k; i++)
            _ans += (int)num[i] *(int) pow(10.0,i);
 
        //printf("\"The Present ");
        for(int i=2;i<strlen(s)-1;i++)
            putchar(s[i]);
        printf(" requires %d square frightometers of paper to wrap\n",_ans);
 
 
    }
    return 0;
}
 
/**************************************************************
    Problem: 1004
    User: YinJianZuiShuai
    Language: C++
    Result: Accepted
    Time:0 ms
    Memory:1908 kb
****************************************************************/

 

 

 

转载于:https://www.cnblogs.com/TreeDream/p/6058814.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值