1004:this is halloween:saving money
Time Limit:1 Sec |
|
Memory limit:128 MB |
Submit:11 |
|
Solved:1 |
Description
The Mayor of Halloween town is always concerned on saving money. When the Pumpkin King, Jack Skelington decided to try he 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 wo Uld only the absolute minimum amount. In order to does, he has asked you, the local computer ghoul to write a problem to calculate the amount of wrapping Pap Er that all of the different types of gifts would take. Thankfully for your, all of the gifts be able to fit in different sizes of rectangular boxes (the Vampire trio Charge of presents this year, got their start in manufacturing things while interns at Ikea). Each present can is represented by a name, and the three dimensions of the Boxa,b,c (0 < a <= b <= c) in Frightome Ters.
The procedure for wrapping the gift are first, a large sheet of wrapping paper is laid on a flat surface. Then, the box was placed on the wrapping paper with one of their ' BC ' faces resting on the wrapping paper. The wrapping paper is folded around the four ' C ' edges and the excess are 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 have the form of a long rectangular tube.
Now more wrapping paper are cut off at the ends of the tube. It is cut flush with the ' a ' edges. Along the ' B ' edges, rectangular flaps remain. These rectangular flaps is cut so this when they is folded along the ' B ' edges, they cover the ' AB ' faces with a 3 f Rightometer wide overlap (overlapping areas shown shaded in the figure). The excess paper can be recycled (the Shadow on the Moon at night are an accomplished paper maker!), so that isn ' t-be ta Ken into account. Calculate The amount of paper, in square frightometers, all box needs in order to be properly wrapped.
Input
Input would begin with a single line containing a integer,n > 0, Wherenis the number types of boxes you need to P Rocess. The Followingnlines start with the name of a product, in single quotes followed by three Integers,a,bandcwhich represent T He three dimensions of the package, as illustrated and the picture above. Following the dimensions, a number of significant digits to include in the answer. The number of significant digits would never is greater than the number of digits in the answer. None of the dimensions would be greater than 10,000.
Outputoutput would 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 would it ever come out? ' 1 2 3 1 ' Killer Bunnies ' 7 2 ' Living head of Joseph Mengele ', Bayi 101 1 ' Barney and friends:the complete Series ' 1 7 3 ' abba:greatest Hits ' 45 78 650 5
Sample Output
The Present Kingdom Hearts Iii:when would it ever come out? Requires square frightometers of paper to wrapthe Present Killer bunnies requires, square frightometers of paper to Wrapthe Present Living Head of Joseph Mengele requires 20000 square frightometers of paper to wrapthe Present Barney and Friends:the complete Series requires 265 square frightometers of paper to wrapthe Present abba:greatest Hits requires 16 9330 Square frightometers of paper to wrap
HINT Source
ACM ICPC South Central USA Regional programming Contest This question OJ still a little problem, or wait for Yang elder brother to change data it, the original title is LA5745 test instructions understand: Packaging gift box, the place plus 3 meters wide belt, ask for at least more Less cloth, only D is a valid number.
#include <bits/stdc++.h>using namespacestd;intnum[ +];intMain () {//freopen ("test.in", "R", stdin); //freopen ("OUT.txt", "w", stdout); intcases; scanf ("%d",&cases); while(cases--) { Chars[10000],t[10000]; memset (s),' /',sizeof(s)); Long Longa,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 LongAns =2* (A*B+A*C+B*C) +6*b +3*C; //printf ("%d\n", ans); intK =0; while(ans) {num[k]= ans%Ten; Ans= ans/Ten; K++; } intpos = k-D; Long Long_ans =0; for(intI=pos; i<k; i++) _ans+= (int) Num[i] * (int) Pow (10.0, i); printf ("\ "The Present"); for(intI=2; I<strlen (s)-1; i++) Putchar (S[i]); printf ("requires%d square frightometers of paper to wrap\ "\ n", _ans); } return 0;}
Csuft 1004 This was halloween:saving money