CSUFT 1004 This is Halloween: Saving Money

1004: This is Halloween: Saving Money

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

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

2011 ACM ICPC South Central USA Regional Programming Contest

此题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;
}
时间: 2024-11-08 20:20:02

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

万圣节问题(Halloween Protection)

万圣节效应指的是结果集中数据移动位置并因此被改变多次.这个效应不同于双读,因为它是有数据修改驱动的,而不是读取查询.要执行一个更行,数据必须先被读取.执行这个要使用两个游标,一个用于读取,另一个用于写入.如果数据在所有的数据读入之前被写入游标更行,那么就有可能出现某行移动位置,并再次被读取,从而再次被更新.理论上,这会永远持续下去.使用索引读取数据,该索引的键值(key)会被查询更新,这是万圣节效应的一个例子.万圣节效应显然非常让人不悦,幸好SQL Server的存储引擎使其免受该效应.要确保可

Halloween Costumes LightOJ - 1422

Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to attend as many parties as he can. Since it's Halloween, these parties are all costume parties, Gappu always selects his costumes in such a way that

HDU 4864(多校)1004 Task

Problem Description Today the company has m tasks to complete. The ith task need xi minutes to complete. Meanwhile, this task has a difficulty level yi. The machine whose level below this task's level yi cannot complete this task. If the company comp

HDU 1004 Let the Balloon Rise【STL&lt;map&gt;】

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 123800    Accepted Submission(s): 48826 Problem Description Contest time again! How excited it is to see balloons floating ar

51Nod - 1004 n^n的末位数字

51Nod - 1004 n^n的末位数字 给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字. Input 一个数N(1 <= N <= 10^9) Output 输出N^N的末位数字 Input示例 13 Output示例 3 题解: 末尾数字,所以在快速迭代幂的时候,只需要考虑末尾数字即可. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstri

Codevs 1004 四子连棋

1004 四子连棋 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 在一个4*4的棋盘上摆放了14颗棋子,其中有7颗白色棋子,7颗黑色棋子,有两个空白地带,任何一颗黑白棋子都可以向上下左右四个方向移动到相邻的空格,这叫行棋一步,黑白双方交替走棋,任意一方可以先走,如果某个时刻使得任意一种颜色的棋子形成四个一线(包括斜线),这样的状态为目标棋局. ● ○ ●   ○ ● ○ ● ● ○ ● ○ ○ ● ○   输入描述 Input

sqlserver -- 解决sqlserver2008“Prevent saving changes that require table re_creation(阻止保存要求重新创建表的更改)”的问题

电脑重装了sqlserver2008 R2(英文版)后,新建数据表,新建字段,发现有个字段类型设置错了,想修改字段类型,而该表已经保存好了,即保存后修改字段属性.但无法保存修改后的设置,提示“Saving changes is not permitted"(具体如下图) 解决方法: 在菜单栏找到Tools->options,找到Designers,然后将Prevent saving changes that require table re_creation前面的勾去掉,保存后即可. 如果

1004 四子连棋

1004 四子连棋 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 在一个4*4的棋盘上摆放了14颗棋子,其中有7颗白色棋子,7颗黑色棋子,有两个空白地带,任何一颗黑白棋子都可以向上下左右四个方向移动到相邻的空格,这叫行棋一步,黑白双方交替走棋,任意一方可以先走,如果某个时刻使得任意一种颜色的棋子形成四个一线(包括斜线),这样的状态为目标棋局. ● ○ ●   ○ ● ○ ● ● ○ ● ○ ○ ● ○   输入描述 In

BestCoder Round #62 (div.2) 1004

好长时间没做比赛了,原来就菜现在更菜,1004的题目没想到div.2赛后只有一个人做出来,做题的时候想到了做法但时间不多自己的奇葩代码不足以在比赛时间debug出来,赛后补了一发: 题目&提交地址在这:http://acm.hdu.edu.cn/showproblem.php?pid=5565 const int INF = 1000000000; const double eps = 1e-8; const int maxn = 10000000 + 10; const int mod = 1