Search This Blog

Showing posts with label Uva. Show all posts
Showing posts with label Uva. Show all posts

Monday, 15 June 2015

UVA 12372-Packing for holiday

 

 Problem Link: Click Here!

 

12372-Packing for holiday


#include<stdio.h>

int main(void){

int i,t,L,W,H;

scanf("%d",&t);

i=1;

while(i<=t){

        scanf("%d %d %d",&L,&W,&H);

        if(L<=20 && W<=20 && H<=20)
                   printf("Case %d: good\n",i);
       else printf("Case %d: bad\n",i);

       i++;
    }

return 0;

}


Sunday, 14 June 2015

369 - Combinations

 Problem Link: Click Here!!

 Solution:


#include <stdio.h>

int main (void) {
    double m,n,a,b,c;

    while(scanf("%lf %lf",&m,&n)==2 && m && n){


        c=1;
        a=m;
        b=m-n;

        if(b>n) b=n;

        while(b) {
            c = c*(a/b);
            a--;
            b--;
        }


        printf("%.0lf things taken %.0lf at a time is %.0lf exactly.\n",m,n,c);

    }

    return 0;
}

Saturday, 13 June 2015

11219 - How old are you?

 Problem Link:Click Here!!


Solution:

#include<stdio.h>
int main()
{

int i,t,y,y1,y2,m1,m2,d1,d2;

scanf("%d",&t);

i=1;

while(i<=t){

scanf("%d/%d/%d",&d1,&m1,&y1);
scanf("%d/%d/%d",&d2,&m2,&y2);

     y=(y1-y2);

            if(m1<m2)
                y--;

            else if(m1==m2)
            {
                if(d1<d2)
                y--;
            }

            if(y<0)
                printf("Case #%d: Invalid birth date\n", i );
            else if(y>130)
                printf("Case #%d: Check birth date\n", i);
            else
                printf("Case #%d: %d\n",i,y);

    i++;

  }

return 0;

}