Search This Blog

Showing posts with label Uva in c. Show all posts
Showing posts with label Uva in c. 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;

}


Friday, 12 June 2015

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