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 ...
随机推荐
- ImportError: No module named setuptools
Python第三方模块中一般会自带setup.py文件,在Windows环境下,我们只需要使用命令 cd c:\Temp\foo python setup.py install 两个命令就可以完成第三 ...
- srcolltop 的用法
document.body.scrollTop用法 网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可 ...
- zjuoj 3600 Taxi Fare
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3600 Taxi Fare Time Limit: 2 Seconds ...
- 王家林 大数据Spark超经典视频链接全集[转]
压缩过的大数据Spark蘑菇云行动前置课程视频百度云分享链接 链接:http://pan.baidu.com/s/1cFqjQu SCALA专辑 Scala深入浅出经典视频 链接:http://pan ...
- linux第1天 fork exec 守护进程
概念方面 文件是对I/O设备的抽象表示.虚拟存储器是对主存和磁盘I/O设备的抽象表示.进程则是对处理器.主存和I/O设备的抽象表示 中断 早期是没有进程这个概念,当出现中断技术以后才出现进程这个概念 ...
- HDU 4718 The LCIS on the Tree(树链剖分)
Problem Description For a sequence S1, S2, ... , SN, and a pair of integers (i, j), if 1 <= i < ...
- Verilog中的specify block和timing check
在ASIC设计中,有两种HDL construct来描述delay信息: 1)Distributed delays:通过specify event经过gates和nets的time,来描述delay; ...
- SQL关于apply的两种形式cross apply和outer apply(转载)
SQL 关于apply的两种形式cross apply 和 outer apply apply有两种形式: cross apply 和 outer apply 先看看语法: <lef ...
- ASP.NET MVC API 路由生成规则
我们都知道调用ASP.NET MVC的某些API函数(诸如:Url.Action.RedirectToAction等)可以生成URL,ASP.NET MVC会根据调用API函数时传入的参数去匹配系统定 ...
- java类的访问权限
1.解析 Java有四种访问权限, 其中三种有访问权限修饰符,分别为private,public和protected,还有一种不带任何修饰符. private: Java语言中对访问权限限制的最窄的修 ...