2011-12-03 19:22:58Morris

[UVA] 12372 - Packing for Holiday

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;
}