Sunday, April 24, 2016

Published April 24, 2016 by with 0 comment

UVA 11984 - A Change in Thermal U -Solution

#include <stdio.h>
int main()
{
    int t, n=1,c,d;
    float cf;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d%d",&c,&d);
        cf=(float)c+((float)d*5.0)/9.0;
        printf("Case %d: %0.2f\n",n++,cf);
    }
    return 0;
}
Read More
      edit
Published April 24, 2016 by with 0 comment

UVA 12554 - A Special "Happy Birthday" Song!!! -Solution

#include <stdio.h>
#include <string.h>
int main()
{
    int t,n,i,temp,temp2;
    char name[101][101];
    char song[16][10]={"Happy","birthday","to","you","Happy","birthday","to","you","Happy","birthday","to","Rujia","Happy","birthday","to","you"};
    scanf("%d",&t);
    for (i=0;i<t;i++)
    {
        scanf("%s",name[i]);
    }
    if (t%16==0) n=t/16;
    else n=(t/16)+1;
    n=n*16;
    for (i=0;i<n;i++)
    {
        temp=i%t;
        temp2=i%16;
        printf("%s: %s\n",name[temp],song[temp2]);
    }
    return 0;
}
Read More
      edit
Published April 24, 2016 by with 1 comment

UVA 11586 - Train Tracks -Solution

#include <stdio.h>
#include <string.h>
int main()
{
    int t,m,f,i,len;
    scanf("%d",&t);
    getchar ();
    while (t--)
    {
        char str[500];
        m=0;
        f=0;
        gets(str);
        len=strlen(str);
        for (i=0;i<len;i++)
        {
            if (str[i]=='M') m++;
            else if (str[i]=='F') f++;
        }
        if (m==f && m>1 && f>1)
        printf("LOOP\n");
        else
        printf("NO LOOP\n");
    }
    return 0;
}
Read More
      edit
Published April 24, 2016 by with 0 comment

UVA 11777 - Automate the Grades -Solution

#include<stdio.h>
int main()
{
    int t,t1,t2,f,a,c1,c2,c3,i=1,avg,sum;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d%d%d%d%d%d%d",&t1,&t2,&f,&a,&c1,&c2,&c3);
        if (c1<=c2 && c1<=c3)
            avg=(c2+c3)/2;
        else if (c2<=c1 && c2<=c3)
            avg=(c1+c3)/2;
        else if (c3<=c1 && c3<=c2)
            avg=(c1+c2)/2;
        sum=t1+t2+f+a+avg;
        if(sum>=90)
            printf("Case %d: A\n",i++);
        else if(sum>=80)
            printf("Case %d: B\n",i++);
        else if(sum>=70)
            printf("Case %d: C\n",i++);
        else if(sum>=60)
            printf("Case %d: D\n",i++);
        else if(sum<60)
            printf("Case %d: F\n",i++);
    }
    return 0;
}
Read More
      edit
Published April 24, 2016 by with 0 comment

UVA 12157 - Tariff Plan : Solution

#include <stdio.h>
int main()
{
    int t,c=1,n,a,mile,juice;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d",&n);
        int mile=0, juice=0;
        while (n--)
        {
            scanf("%d",&a);
            mile+=((a/30)+1)*10;
            juice+=((a/60)+1)*15;
        }
        printf("Case %d: ",c++);
        if (mile<juice)
            printf("Mile %d\n",mile);
        else if (juice<mile)
            printf("Juice %d\n",juice);
        else
            printf("Mile Juice %d\n",mile);
          
    }
    return 0;
}
Read More
      edit
Published April 24, 2016 by with 0 comment

UVA 12015 - Google is Feeling Lucky : Solution

#include <stdio.h>
#include <string.h>

int main()
{
    int t,c=1,r[10],max,i;
    char str[10][100];
    scanf("%d",&t);
    while (t--)
    {
        scanf("%s%d",&str[0],&r[0]);
        max=r[0];
        for (i=1;i<10;i++)
        {
            scanf("%s%d",&str[i],&r[i]);
            if (max<r[i]) max=r[i];
        }
        printf("Case #%d:\n",c++);
        for (i=0;i<10;i++)
            if (r[i]==max) printf("%s\n",str[i]);
    }
    return 0;
}
Read More
      edit
Published April 24, 2016 by with 0 comment

UVA 11942 - Lumberjack Sequencing : Solution

#include <stdio.h>
int main()
{
    int t,n,max,min,maxflag,minflag;
    scanf("%d",&t);
    printf("Lumberjacks:\n");
    while (t--)
    {
        max=100;
        min=0;
        maxflag=1;
        minflag=1;
        int i=10;
        while (i--)
        {
            scanf("%d",&n);
            if (min>n) minflag=0;
            if (max<n) maxflag=0;
            min=n;
            max=n;
        }
        if (maxflag!=minflag) printf("Ordered\n");
        else printf("Unordered\n");
    }
    return 0;
}
Read More
      edit