24h購物| | PChome| 登入
2011-12-03 19:22:58| 人氣594| 回應0 | 上一篇 | 下一篇

[UVA] 12372 - Packing for Holiday

推薦 0 收藏 0 轉貼0 訂閱站台

Mr. Bean used to have a lot ofproblems packing his suitcase for holiday. So he is very careful for thiscoming holiday. He is more serious this time because he is going to meet his fiancéeand he is also keeping frequent communication with you as a programmer friendto have suggestions. He gets confused when he buys a gift box for his fiancéebecause he can't decide whether it will fit in his suitcase or not. Sometimes abox doesn't fit in his suitcase in one orientation and after rotating the boxto a different orientation it fits in the suitcase. This type of behavior makeshim puzzled.

 

So to make things much simpler hebought another suitcase having same length, width and height, which is 20inches. This measurement is taken from inside of the box. So a box which haslength, width and height of 20 inches will just fit in this suitcase. He alsodecided to buy only rectangular shaped boxes and keep a measuring tape in hispocket. Whenever he chooses one gift box, which must be rectangular shaped, hequickly measures the length, width and height of the box. But still he can'tdecide whether it will fit in his suitcase or not. Now he needs your help.Please write a program for him which calculates whether a rectangular box fitsin his suitcase or not provided the length, width and height of the box. Notethat, sides of the box must be parallel to the sides of the suitcase.

 

Input

Input starts with an integer T (T ≤ 100), which indicatesthe number of test cases.

 

Each of the next T line containsthree integers L, W and H (1 ≤ L, W, H ≤ 50) denoting the length,width and height of a rectangular shaped box.

 

Output

For each test case, output asingle line. If the box fits in the suitcase in any orientation having thesides of the box is parallel to the sides of the suitcase, this line will be “Case #: good”, otherwise it willbe “Case #: bad”. In youroutput # will be replacedby the case number.

 

Please see the sample input and sample output for exactformat.

 

SampleInput                               Output for Sample Input

2

20 20 20

1 2 21

Case 1: good

Case 2: bad




#include<stdio.h>
int main() {
    int T, L, W, H, C = 0;
    scanf("%d", &T);
    while(T--) {
        scanf("%d %d %d", &L, &W, &H);
        printf("Case %d: ", ++C);
        if(L > 20 || W > 20 || H > 20)
            puts("bad");
        else
            puts("good");
    }
    return 0;
}

台長: Morris
人氣(594) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA] 681 - Convex Hull Finding
此分類上一篇:[UVA] 12195 - Jingle Composing

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文