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
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
#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的更多相关文章
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- bzoj 1004 Cards
1004: [HNOI2008]Cards Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有 多少种染色方案,Sun ...
- 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 ...
- 1004. Counting Leaves (30)
1004. Counting Leaves (30) A family hierarchy is usually presented by a pedigree tree. Your job is ...
- Lightoj 题目1422 - Halloween Costumes(区间DP)
1422 - Halloween Costumes PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...
- Android Saving Data(二)
Saving File android读写文件的形式和普通的java IO的方式并没有什么不同,唯一有所限制的是当我们创建文件的时候不能够在像javaSE那样随意了.一般android读写文件有两种形 ...
- Android Saving Data(一)
Saving Key-value Sets 保存键值对 SharedPreferences只能用来保存一些简单的数据,并且这些数据可以是共享的,也可以是私有的. SharedPreferences没 ...
- POJ做题笔记:1000,1004,1003
1000 A+B Problem 题目大意:输入两个数a和b,输出他们的和. 代码: #include <stdio.h> int main() { int a, b; while (sc ...
随机推荐
- Highcharts选项配置详细说明文档(zz)
http://www.helloweba.com/view-blog-156.html Highcharts提供大量的选项配置参数,您可以轻松定制符合用户要求的图表,目前官网只提供英文版的开发配置说明 ...
- Android Support Font 安卓系统支持字体(配图)
测试了一台安卓机器,发现所有字体显示都一样.
- SQL in查询
--sal为员工工资 select * from emp;
- CSS3 auto revolution practitioner!
1.html <!DOCTYPE html> <html> <head> <title></title> <meta charset= ...
- iOS 检查版本号的代码
- (void)checkNewVersion{ if ([@"appStore" isEqualToString:CHANNEL]) { AFHTTPRequestOperati ...
- C++初学者 const使用详解
关于C++中的const关键字的用法非常灵活,而使用const将大大改善程序的健壮性,参考了康建东兄的const使用详解一文,对其中进行了一些补充,写下了本文. 1. const常量 如: cons ...
- linux时间的查看与修改
1.查看时间和日期 date 2.设置时间和日期 将系统日期设定成1996年6月10日的命令 date -s 06/22/96 将系统时间设定成下午1点52分0秒的命令 date -s 13:52:0 ...
- jsformat插件
Package Control Package Control 是用来管理 Sublime Text 2 的插件的插件. 也是装完后第一个要安装的插件. 首先打开 ctrl+`, 并在打开的 st2 ...
- VMware搭建 sql server2012集群加节点 KB953748
--node4加入节点前 将共享磁盘挂载到node4,仅测试验证磁盘挂载,否则会导致整个集群磁盘offline切换 --node4 加入集群报错,无法访问计算机“node4” 0.public网卡勾选 ...
- 在TVideoGrabber中如何在预览时设置相机属性
在使用TVideoGrabber进行预览时,如何设置相机的属性呢?比如曝光.对比度.亮度等. 下面来看一下,如何通过编程来调整这些设置: ——通过指定VideoDevice属性(在VideoDevic ...