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[]; int main()
{
//freopen("test.in","r",stdin);
//freopen("out.txt","w",stdout);
int cases;
scanf("%d",&cases);
while(cases--)
{ char s[],t[];
memset(s,'\0',sizeof(s));
long long a,b,c,d;
while()
{
scanf("%s",t);
strcat(s," ");
strcat(s,t);
if(s[strlen(s)-]=='\'')
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 = *(a*b+a*c+b*c) + *b + *c;
// printf("%d\n",ans); int k = ;
while(ans)
{
num[k] = ans % ;
ans = ans / ;
k++;
} int pos = k - d; long long _ans = ;
for(int i=pos; i<k; i++)
_ans += (int)num[i] *(int) pow(10.0,i); //printf("\"The Present ");
for(int i=;i<strlen(s)-;i++)
putchar(s[i]);
printf(" requires %d square frightometers of paper to wrap\n",_ans); }
return ;
} /**************************************************************
Problem: 1004
User: YinJianZuiShuai
Language: C++
Result: Accepted
Time:0 ms
Memory:1908 kb
****************************************************************/

CSUFT 1004 This is Halloween: Saving Money的更多相关文章

  1. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  2. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. bzoj 1004 Cards

    1004: [HNOI2008]Cards Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有 多少种染色方案,Sun ...

  4. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  5. 1004. Counting Leaves (30)

    1004. Counting Leaves (30)   A family hierarchy is usually presented by a pedigree tree. Your job is ...

  6. Lightoj 题目1422 - Halloween Costumes(区间DP)

    1422 - Halloween Costumes   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...

  7. Android Saving Data(二)

    Saving File android读写文件的形式和普通的java IO的方式并没有什么不同,唯一有所限制的是当我们创建文件的时候不能够在像javaSE那样随意了.一般android读写文件有两种形 ...

  8. Android Saving Data(一)

    Saving Key-value Sets  保存键值对 SharedPreferences只能用来保存一些简单的数据,并且这些数据可以是共享的,也可以是私有的. SharedPreferences没 ...

  9. POJ做题笔记:1000,1004,1003

    1000 A+B Problem 题目大意:输入两个数a和b,输出他们的和. 代码: #include <stdio.h> int main() { int a, b; while (sc ...

随机推荐

  1. [原创]java WEB学习笔记64:Struts2学习之路--主题

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  2. 为什么接口要规定成员变量必须是public static final的呢?(转)

    在interface里面的变量默认都是public static final 的.所以可以直接省略修饰符: String param="ssm"://变量需要初始化 为什么接口要规 ...

  3. 从一简单程序看C语言内存分配

    int main13(){ char buf[20]="aaaa"; char buf2[] = "bbbb"; char *p1 = "111111 ...

  4. sql 通过游标 拆分xml结构

    -----------------------定义游标变量------------------------------------------  DECLARE @propertyid INT   D ...

  5. Tomcat上的项目部署到WebLogic上の注意事项

    1.修改web.xml: <!-- <display-name>weboutweb</display-name> --> <!-- 注释掉 display-n ...

  6. linux下调整音量大小

    不得不说,在linux下整音频和视频真是不容易.在windows中自带了关于音频和视频的工具,在linux下要两眼一抹黑地使用命令进行操作. 主要还是在linux下没找到合适的gui的调整工具. 几番 ...

  7. 使用Graham扫描法求二维凸包的一个程序

    #include <iostream> #include <cstring> #include <cstdlib> #include <cmath> # ...

  8. Android学习参考

    收到一些朋友的微博私信,说能不能给Android新手们一些指导,我只能说指导谈不上,毕竟我也很多东西正在学习中,与此同时一大学同学准备转行Android,可以说是从头开始,那么我就姑且以一个过来人的身 ...

  9. JAVA NIO复习笔记

    1. JAVA NIO是什么? 从JDK1.4开始,java提供了一系列改进的输入/输出处理的新功能,这些功能被统称为新IO(New IO,简称NIO),新增了许多用于处理输入/输出的类,这些类都被放 ...

  10. PHP判断客户端是PC web端还是移动手机端方法

    PHP判断客户端是PC web端还是移动手机端方法需要实现:判断手机版的内容加上!c550x260.jpg后缀变成缩略图PHP用正则批量替换Img中src内容,用正则表达式获取图片路径实现缩略图功能 ...