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 ...
随机推荐
- devexpress13学习系列(一)PDFViewer(2)
DevExpress.XtraPdfViewer Namespace 该命名空间下,保留着pdfviewer组件需要的类,主要有: Class Description PdfCurrentPa ...
- 基于Qt实现的截图小程序
在最近做的行人检测项目中,由于需要训练分类器,而分类器的训练又需要有一个一定长宽的样本.为了方便样本的采集,因此实现了这样的一个截图程序.该程序的主要功能是加载视频到程序中,程序可以对视频进行播放.暂 ...
- ASP.NET的一般处理程序对图片文件的基本操作
以一个小项目为例: 验证码: public class VerifyCodeHelper { public VerifyCodeHelper() { this.ran = new Random(); ...
- JavaScript: basis
ref: http://www.imooc.com/code/387 1. html里直接嵌入js: <!DOCTYPE HTML> <html> <head> & ...
- oracle 复杂语句
select nvl(sum1,'0')as sum1,nvl(sum2,'0') as sum2,da2 from( select count(*) as sum1,substr(APPLY_DAT ...
- Android中实现app版本更新
1,获取本地程序apk版本,并开启服务(下面这段代码一般在主Activity中的onCreate()方法中执行的,并开启后台服务下载新版本的apk) //获取apk包文件的管理者对象 PackageM ...
- smarty简单介绍
smarty简单介绍 示意图如下 简单介绍smarty.class.php类的大体内容,如下: <?php class Smarty //此类就是libs中的Smarty.class.php类 ...
- 关于teleport_pro使用过程中的一点疑惑
在我新建工程的时候,有两个选项,一个是"new project wizard"另一个是"new project",然后就纠结了,我应该使用那个呢? 使用第一个的 ...
- yii2验证码的使用
1.控制器中 public function actions() { return [ 'captcha' => [ ...
- MapReduce之Writable相关类
当要在进程间传递对象或持久化对象的时候,就需要序列化对象成字节流,反之当要将接收到或从磁盘读取的字节流转换为对象,就要进行反序列化.Writable是Hadoop的序列化格式,Hadoop定义了这样一 ...