Search This Blog

Saturday 25 July 2015

UVA SOME EASY Problems FOR BEGINNERS

UVA Some Easy Problems For BEGINNERS

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

10035-Primary Arithmatic

 Problem Link:Click Here!!

 

Problem Solution:

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

long long int a,b,res,c,d;
int o;

while(scanf("%lld %lld",&a,&b)==2){

o=0;
res=0;

if(a==0 && b==0)break;

else{
        if(a<b){c=a;
        a=b;
        b=c;
     }

      while(a!=0){
       c=a%10;
       a=a/10;
       d=b%10;
       b=b/10;
       res=c+d+res;

      if(res>=10){o++;
               res=res/10;
                  }

       else res=0;
       }

if(o==0)printf("No carry operation.\n");
        else if(o==1)printf("%d carry operation.\n",o);
                 else if(o>1)printf("%d carry operations.\n",o);
              }
      }
return 0;
}

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;

}

Friday 12 June 2015

11799 - Horror Dash

11799 - Horror Dash

Problem Link: Click Here!

Solution:

#include<stdio.h>

int main(void){
int i,t,m,v=0;
char ch;
i=1;
scanf("%d",&t);

while(i<=t){
ch='a';
v=0;

while(ch !='\n'){
scanf("%d",&m);
scanf("%c",&ch);
if(m>v)v=m;
}

printf("Case %d: %d\n",i,v);

i++;
}

return 0;
}

10879 - Code Refactoring

10879 - Code Refactoring

Problem Link: Click Here!

Solution:

#include<stdio.h>
int main(void){
int i,t,m,ao[5];
long long int a,j;
scanf("%d",&t);
i=1;
while(i<=t){
m=0;
scanf("%lld",&a);
for(j=2;j<=a/2;j++){
if(a%j==0){
        ao[m]=j;
        ao[++m]=a/j;
        m++;
        }
if(m==4)break;
}
printf("Case #%d: %lld = %d * %d = %d * %d\n",i,a,ao[0],ao[1],ao[2],ao[3]);
i++;
}
return 0;
}