Sunday, May 20, 2012

UVA Solution for 10493

//10493
#include<stdio.h>
int main()
{
    int a,b,ans;
    while(scanf("%d%d",&a,&b)==2)
    {
    if(a==0)
    break;
    else
         {
          if(a==1)
             {
                  if(b==1)
                          {
                           printf("%d %d Multiple\n",a,b);
                           continue;
                           }
                  else
                      {
                       printf("%d %d Impossible\n",a,b);
                       continue;
                       }
             }
             if( (b-a)%(a-1)==0)
                 {
                 ans=(a+1)+a*((b-a)/(a-1));
                 printf("%d %d %d\n",a,b,ans);
                 }
             else
             {
                 printf("%d %d Impossible\n",a,b);
             }
            
         }
    }
}

UVA Solution for 900

#include<stdio.h>
int fibon(int n)
{
    int i;
    int fib[100]={0};
    fib[0]=1;
    fib[1]=1;
    for(i=2;i<=n;i++)
    {
    fib[i]=fib[i-2]+fib[i-1];
    }
    return fib[n];
}
int main()
{
    int n,ans;
    while(scanf("%d",&n)==1)
    {
    if(n==0)
    break;
    else
        {
            ans=fibon(n);
            printf("%d\n",ans);
        }
    }
}


/*
if time limit execcds then
#include <stdio.h>
char * fib[] = {"1","2","3","5","8","13","21","34","55","89","144","233","377","610","987","1597",
"2584","4181","6765","10946","17711","28657","46368","75025","121393","196418","317811","514229",
"832040","1346269","2178309","3524578","5702887","9227465","14930352","24157817","39088169","63245986"
,"102334155","165580141","267914296","433494437","701408733","1134903170","1836311903","2971215073",
"4807526976","7778742049","12586269025","20365011074"};
int main() {
    int n;
    while(1) {
        scanf("%d",&n);
        if(!n) break;
        puts(fib[n-1]);
    }
}
*/

UVA Solution for 880

//880
#include<stdio.h>
#include<math.h>
int main()
{
    long n,r,k;
    while(scanf("%ld",&n)==1)
    {
    k=sqrt(2*n)+.5;
    r=k*(k+1)/2-n;
    printf("%ld/%ld\n",r+1,k-r);
    }
}

UVA Solution for 494

//494
#include <stdio.h>
int main()
{
    char name[1000];
    int i,p;
    while(gets(name))
   
{
p=0;          
for(i=0;name[i]!='\0';i++)
{                   
    if(
          ((name[i]>='a'&& name[i]<='z')||
          (name[i]>='A' && name[i]<='Z'))
          &&
          (name[i+1]<'a' || name[i+1]>'z') &&
           (name[i+1]<'A' || name[i+1]>'Z')     
      )
          p++;
      }
      printf("%d\n",p);
    }
}

UVA Solution for 278

//278
#include<stdio.h>

int min(int a, int b)
{
    if(a>b)
    return b;
    else
    return a;
}

int main()
{
    int a,b,ans,n,i;
    char ch,sor[100];
    scanf("%d",&n);
    gets(sor);
    while(n--)
    {
        gets(sor);
       sscanf(sor,"%c %d %d",&ch,&a,&b);

       switch(ch)
       {
       case 'r':
        ans=min(a,b);
        printf("%d\n",ans);
        break;    
          case 'Q':
        ans=min(a,b);
        printf("%d\n",ans);
        break;  
         case 'K':
        ans=((a+1)/2)*((b+1)/2);
        printf("%d\n",ans);
        break;
      case 'k':
        ans=((a*b)+1)/2;
        printf("%d\n",ans);
        break;      
       
    }
}
}


UVA Solution for 136

//136
/*
#include<stdio.h>
int main()
{
    printf("The 1500'th ugly number is 859963392.");
}
*/

#include <stdio.h>
int main()
{
  puts("The 1500'th ugly number is 859963392.");
  return 0;
}

UVA Solution for 11764

//11764
#include<stdio.h>
int main()
{
    int high,low,test,i,n,j,x[102]={0};
    int kase;
    while(scanf("%d",&test)==1)
    {
    kase=1;
    for(j=0;j<test;j++)
       {
       scanf("%d",&n);
          {
          for(i=0;i<n;i++)
             {
             scanf("%d",&x[i]);
             }
          high=low=0;
          
           for(i=0;i<n-1;i++)
             {
             if(x[i+1]<x[i])
             low++;
             else if (x[i+1]>x[i])
             high++;
             }
           
          }
         printf("Case %d: %d %d\n",kase,high,low);
         kase++;
       }
     
    }
}

UVA Solution for 11689

//11689
#include<stdio.h>
int main()
{
    long int f,e,c,i,kase,n,ans,total,x;
    while(scanf("%ld",&kase)==1)
    {
    for(i=0;i<kase;i++)
        {
        scanf("%ld%ld%ld",&e,&f,&c);
        total=e+f;
        ans=0;
        for(;;)
               {
               x=total/c;
               ans=ans+x;
               total=total/c+total%c;
               if(total<c)
               break;
               }
               printf("%ld\n",ans);
        }
    }
}

UVA Solution for 11636

//11636
#include <stdio.h>
#include <math.h>
int main()
{
    int num,ans,i;
    int kase=0;
    while(scanf("%d",&num)==1)
    {
   
    if(num<0)
    break;
    else
        {
            
            for(i=0;i<num;i++)
            {
            if(pow(2,i)>=num)
              {
               ans=i;
               break;
               }
            }
                kase++;
        printf("Case %d: %d\n",kase,ans);
   
        }
    }
   
}

UVA Solution for 11530

//11530
#include<stdio.h>
#include<string.h>
int main()

{
int p,i,n,len,k;
char ch[102];
while(scanf("%d",&n)==1)
   {
   for(k=0;k<=n;k++)
       {
       gets(ch);
        p=0;
       len=strlen(ch);
       for(i=0;i<=len;i++)
          {
                       
          if (ch[i]=='a'|| ch[i]=='d'|| ch[i]=='g'|| ch[i]=='j'|| ch[i]=='m'||
          ch[i]=='p'|| ch[i]=='t'|| ch[i]=='w'|| ch[i]==' ' )
          p=p+1;
          else if  (ch[i]=='b'|| ch[i]=='e'|| ch[i]=='h'|| ch[i]=='k'|| ch[i]=='n'||
          ch[i]=='q'|| ch[i]=='u'|| ch[i]=='x' )
          p=p+2;
         
          else if (ch[i]=='c'|| ch[i]=='f'|| ch[i]=='i'|| ch[i]=='l'|| ch[i]=='o'||
          ch[i]=='r'|| ch[i]=='v'|| ch[i]=='y' )
          p=p+3;
          else if(ch[i]=='s'||ch[i]=='z')
          p=p+4;
          }
          if(k!=0)
          printf("Case #%d: %d\n",k,p);
       }
   }
}

UVA Solution for 11547

//11547
#include<stdio.h>
int main()
{
    long int ans,t,n,i;
    while(scanf("%ld",&t)==1)
    {
    for(i=0;i<t;i++)
      {
      scanf("%ld",&n);
      n*=567;
      n/=9;
      n+=7492;
      n*=235;
      n/=47;
      n-=498;
      n/=10;
      ans=n%10;
      if(ans<0)
      ans*=(-1);
      printf("%ld\n",ans);
      }
    }
}

UVA Solution for 11192

//11192
#include<stdio.h>
#include<string.h>
int main()
{
    char ch[101];
    int len,i,j,end,start,a,group;
    while(scanf("%d\n",&group)==1)
    {
    if(group==0)
    break;
    else
    {
        gets(ch);
        len=strlen(ch);
        a=len/group;
        start=0;
        end=0;
        for(i=0;i<len;i++)
        {
        if( (i+1)%a==0)
          {
          end=i;
          for(j=end;j>=start;j--)
            {
            printf("%c",ch[j]);
            }
            start=end+1;
          }
        }
    }
 printf("\n");
    }
}

UVA Solution for 11172

///11172
#include<stdio.h>
int main()
{
    long int t,a,b,i;
    while(scanf("%ld",&t)==1)
    {
     for(i=0;i<t;i++)
       {
       scanf("%ld%ld",&a,&b);
       if(a==b)
       printf("=\n");
       else if(a>b)
       printf(">\n");
        else if(a<b)
       printf("<\n");
       }
    }
return 0;
}


UVA Solution for 10970

#include <stdio.h>

int main()
{
    int m,n,c;
    while(scanf("%d%d",&m,&n)==2)
    {
              c=m*n-1;
              printf("%d\n",c);
                                 }

}

UVA Solution for 11152

//11152
#include<stdio.h>
#include <math.h>
int main()
{
    double red,yellow,voilate,s,a,b,c,at,total,ss;
    while(scanf("%lf%lf%lf",&a,&b,&c)==3)
    {
    s=(a+b+c)/2; 
    at=sqrt(s*(s-a)*(s-b)*(s-c));
   
    red=3.141592653589793*pow((at/s),2);
    voilate=at-red;
   
    total=3.141592653589793*pow(((a*b*c)/(4*at)),2);
    yellow=total-(red+voilate);
   
    printf("%.4lf %.4lf %.4lf\n",yellow,voilate,red);
    }
}

UVA Solution for 11150

//11150
#include<stdio.h>
int main()
{
    long int cola,half,total;
    while(scanf("%ld",&cola)==1)
    {
    half=cola/2;
    total=cola+half;
    printf("%ld\n",total);
    }
}

UVA Solution for 11044

//11044
#include<stdio.h>
int main()
{
int i,z,a,b;
while(scanf("%d",&z)==1)
  {
   for(i=0;i<z;i++)
     {
     scanf("%d%d",&a,&b);
     a=(a/3)*(b/3);
     printf("%d\n",a);
     }
   }
}

UVA Solution for 10812

//10812
#include<stdio.h>
int main()
{
    int c,a,b,s,d,i;
    while(scanf("%d",&c)==1)
    {
    for(i=0;i<c;i++)
    {
    scanf("%d%d",&s,&d);
    a=s+d;
    b=s-d;
  
     if((a%2)||(b%2)||(b<0))
    printf("impossible\n");
    else
    printf("%d %d\n",a/2,b/2);
    }
}
return 0;
}

UVA Solution for 11498

//11498
#include<stdio.h>


int main()
{
    long n,x,x1,y1,y,t1,i;
    while(scanf("%ld",&n)==1)
    {
    if(n==0)
    break;
    scanf("%ld%ld",&x,&y);
    for(i=0;i<n;i++)
      {
      scanf("%ld%ld",&x1,&y1);
      if(x==x1||y==y1)
      printf("divisa\n");
      if(x1>x&&y1>y)
      printf("NE\n");
      if(x1<x&&y1>y)
      printf("NO\n");
        if(x1<x&&y1<y)
      printf("SO\n");
        if(x1>x&&y1<y)
      printf("SE\n");     
      }
    }
}

UVA Solution for 11479

//11479
#include<stdio.h>
int main()
{
    long a,b,c,t,i,max;
    while(scanf("%ld",&t)==1)
   
    {
    for(i=0;i<t;i++)
    {
    scanf("%ld%ld%ld",&a,&b,&c);   
    max=0;
    if(a>max) max=a;           
    if(b>max) max=b;
    if(c>max) max=c;
   
    if ((a+b+c-max)<=max)
    printf("Case %d: Invalid\n",i+1);
    else if(a==b&&b==c)
    printf("Case %d: Equilateral\n",i+1);
    else if(a==b||a==c||b==c)
    printf("Case %d: Isosceles\n",i+1);
    else if(a!=b&&a!=c&&b!=c)
    printf("Case %d: Scalene\n",i+1);
    }
   
    }
}

UVA Solution for 11462

//11462
#include<stdio.h>
#define max 2000005
int main()
{
    int m,n,x[max],i,j,k;
    while(scanf("%d",&n)==1)
    {
if(n==0)
break;

    for(i=1;i<=n;i++)
      {
      scanf("%d",&x[i]);
      }
      m=0;
    for(i=0;i<=110;i++)
    {
    for(j=1;j<=n;j++)
      {
      if(x[j]==i && m<n-1)
        {
         printf("%d ",i);
         m++;
         }
         if(x[j]==i && m==n-1)
        {
         printf("%d\n",i);
         m++;
         }
         if(m==n)
         break;
        }
      }
     
    }
    return 0;
}

UVA Solution for 11462

//11462
#include<stdio.h>
int main()
{
    int m,n,x[2000001],i,j,k;
    while(scanf("%d",&n)==1)
    {
if(n==0)
break;
    for(i=1;i<=n;i++)
      {
      scanf("%d",&x[i]);
      }
      m=0;
    for(i=0;i<120;i++)
    for(j=1;j<=n;j++)
      {
      if(x[j]==i && m<=n-1)
        {
         printf("%d ",i);
         m++;
        }
      }
     
    }
}

UVA Solution for 10940

//10940
#include<stdio.h>
#include<math.h>
int main()
{
    long int input,p,i,x;
    while(scanf("%ld",&input)==1)
    {
    if(input==0)
    break;
    for(i=0;i<=19;i++)
       {
       p=pow(2,i);
       if(p>=input)
       break;
       }
     x=p-(p-input)*2;
     printf("%d\n",x); 
    }
}

UVA Solution for 11461

//11461
#include<stdio.h>
#include<math.h>
int main()
{
    long k,i,x,n1,n2,num1,num2;
    while(scanf("%ld%ld",&n1,&n2)==2)
    {
    if(n1==0 && n2==0)
    break;
    else
      {
          if(n1>n2)
          {
               int temp=n1;
               n1=n2;
               n2=temp;
          }
         
          num1=sqrt(n1);
          num2=sqrt(n2);
          k=0;
          for(i=num1;i<=num2;i++)
          {
          x=pow(i,2);
          if(x>=n1 && x<=n2)
          k++;
          else if(x>n2)
          break;
          }
      }
   
    printf("%ld\n",k);
    }
   
}

UVA Solution for 11000

//11000
#include<stdio.h>
#include<string.h>
int main()
{
    long int n,a,b,srs[1000],c;
    //a=male-1
    //c=total-1
    while(scanf("%ld",&n)==1)
    {
    if(n==-1)
    break;
    a=srs[0]=1;
    b=srs[1]=2;
    for(int i=2;i<=n+1;i++)
      {
            srs[i]=c=a+b;
            a=b;
            b=c;
      }
      printf("%ld %ld\n",srs[n]-1,srs[n+1]-1);
    }
}

UVA Solution for 10929

//10929
#include<stdio.h>
#include<string.h>
int main()
    {
    char num[1002];
    int n,i,k,len,r;
    while(gets(num))
       {
          len=strlen(num);
          if(len==1 && num[0]=='0')
          break;
          r=0;
          k=0;
          n=0;
          for(i=0;i<len;i++)
          {
             r=(n*10)+(num[i]-48);
             n=r%11;
             if(n==0 && i==len-1)
             k++;
          }
          if(k>0)
          printf("%s is a multiple of 11.\n",num);
          else
          printf("%s is not a multiple of 11.\n",num);
       }
    }                 

UVA Solution for 10921

//10921
#include<stdio.h>
int main(){
char ch;

while(scanf("%c",&ch)==1)
{
if (ch=='A'||ch=='B'||ch=='C') printf("2");
else if (ch=='D'||ch=='E'||ch=='F') printf("3");
else if (ch=='G'||ch=='H'||ch=='I') printf("4");
else if (ch=='J'||ch=='K'||ch=='L') printf("5");
else if (ch=='M'||ch=='N'||ch=='O') printf("6");
else if (ch=='P'||ch=='Q'||ch=='R'||ch=='S') printf("7");
else if (ch=='T'||ch=='U'||ch=='V') printf("8");
else if (ch=='W'||ch=='X'||ch=='Y'||ch=='Z') printf("9");
else printf("%c",ch);
}
return 0;
}

UVA Solution for 10784

//10784
#include<stdio.h>
#include<math.h>
int main()
{
long n,kase=1,x;
while(scanf("%ld",&n)==1)
{
if(n==0)
break;
//x=ceil(3+sqrt(9+8*n)/2);
x=ceil((3+sqrt(9+8*n))/2);

printf("Case %ld: %ld\n",kase,x);
kase++;
}
}

UVA Solution for 10783

//10783
#include<stdio.h>

int main()
{
    int j,i,sum,t,a,b;
   
    while(scanf("%d",&t)==1)
    {
for(i=1;i<=t;i++){
scanf("%d%d",&a,&b);

   
    if(b<a)
    {
 int temp=a;
a=b;
b=temp;
}
    sum=0;
   
    for(j=a;j<=b;j++)
    {
  if((j%2)==1)
    sum+=j;  
            
}
      printf("Case %d: %d\n",i,sum);
                
      }
}
return 0; 
}

UVA Solution for 10696

//10696
#include<stdio.h>
int main()
{
    long int n,res,rs;
    while(scanf("%ld",&n)==1)
    {
    if(n==0)
    break;
    else if (n>=101)
    {
         res=n-10;
   
    printf("f91(%ld) = %ld\n",n,res);
             }     
            
             else if(n<=100)
            
             {
                 
               printf("f91(%ld) = 91\n",n);
              }
                       }
}

UVA Solution for 10633

//10633

#include<stdio.h>
int main()
{
    unsigned long int n,x;
    while(scanf("%ld",&n)==1)
    {
    if(n==0)
    break;
    x=(n*10)/9;
    if(n%9==0)
    printf("%ld %ld\n",x-1,x);
    else
   printf("%ld\n",x);
                            }
}

UVA Solution for 10499

//10499
#include<stdio.h>

int main()
{
long int n,r;
while(scanf("%ld",&n)==1)
{
if(n<0) break;
if (n==1) r=0;
else r=n*25;
printf("%ld%\n",r);
}
return 0;
}

UVA Solution for 10432

//10432

#include<math.h>
#include<stdio.h>
int main()
{
    double r,b,n,area;
    while(scanf("%lf%lf",&r,&n)==2)
    {
    b=sin((2*3.14159265358979)/n);//pi
    area=(r*r*n*b)/2;
    printf("%.3lf\n",area);
    }
}

UVA Solution for 10424

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

int sum(int n)
{
    int sum=0;
    while(n>0)
    {
    sum=sum+n%10;
    n=n/10;
    }
    return sum;
}

int main()
{
   char name1[26],name2[26];
   int i,j,k,sum1,sum2,len1,len2;
   float ratio=0;
   while(gets(name1))
   {
   gets(name2);
  
    sum1=0,sum2=0;
    len1=strlen(name1);
    len2=strlen(name2);
    for(i=0;i<len1;i++)
      {
      if( (name1[i]>='a') &&(name1[i]<='z') )
      sum1=sum1+(name1[i]-96);
      else if ( (name1[i]>='A') &&(name1[i]<='Z') )
      sum1=sum1+(name1[i]-64);
      }
   //
 // printf("sum1 is %d",sum1); 
    for(i=0;i<len2;i++)
      {
      if( (name2[i]>='a') &&(name2[i]<='z') )
      sum2=sum2+(name2[i]-96);
      else if ( (name2[i]>='A') &&(name2[i]<='Z') )
      sum2=sum2+(name2[i]-64);
      }
  //   printf("\nsum2 is %d\n",sum2);  
     
      i=0;
   while(sum1>9)
    {
    sum1=sum(sum1);
    }
    //
  // printf("sum00001 is %d",sum1); 
  
  
        i=0;
   while(sum2>9)
    {
    sum2=sum(sum2);
    }
    //
  // printf("\nsum00002 is %d",sum2); 
   ratio=((float)sum1/sum2)*100;
  
   if(ratio<=100)
    printf("%.2f %c\n",ratio,'%');
    
    else if (ratio>100)
    {
         ratio=((float)sum2/sum1)*100;
         printf("%.2f %c\n",ratio,'%');
     }        
   }
}

UVA Solution for 10347

//10347
#include<stdio.h>
#include<math.h>
int main()
{
    double a,b,c,max,result,area;
     while(scanf("%lf%lf%lf",&a,&b,&c)==3)
    {
    max=0;
    if(a>max)
    max=a;
    if(b>max)
    max=b;
    if(c>max)
    max=c;
   
    if(a==0||b==0||c==0)
    printf("-1.000\n");
   
   else if((a+b+c-max)<=max)
    printf("-1.000\n");
   
    else
    {
     result=(2*(a*a*b*b+b*b*c*c+c*c*a*a))-(pow(a,4)+pow(b,4)+pow(c,4));
     area=(sqrt(result))/3;
     printf("%.3lf\n",area);  
    }   
   
   
    }
}

UVA Solution for 10346

//10346
#include<stdio.h>
int main()
{
    int x,n,sum,k;
    while(scanf("%d%d",&n,&k)==2)
    {
    x=sum=n;
    while(x>=k)
               {
               sum=sum+(x/k);
               x=x/k+x%k;
               }
    printf("%d\n",sum);
    }
}

UVA Solution for 10302

//10302

#include <stdio.h>
#include <math.h>
int main()
{            long n,xx;
                 while(scanf("%ld",&n)==1)
                 {
                 xx=(n*n*(n+1)*(n+1))/4;
                printf("%ld\n",xx);
                 }
}

UVA Solution for 10300

//10300
#include <stdio.h>
int main()
{
    long int kase,farmer,a,b,c,prem,i,j;
   
    while(scanf("%ld",&kase)==1)
      {
      for(i=1;i<=kase;i++)
              {
              prem=0;
              scanf("%ld",&farmer);
              {
              for(j=1;j<=farmer;j++)
                 {
                 scanf("%ld%ld%ld",&a,&b,&c);
                 prem=prem+a*c;
                 }
                  printf("%ld\n",prem); 
                  }
                  }
                  }     
  return 0;
}

UVA Solution for 10222

#include<stdio.h>
#include<string.h>
int main()
{
char l[200];
int i,n,k,len;
while(gets(l)){
len=strlen(l);
for(i=0;i<len;i++){
switch(l[i]){
case ']': printf("p"); break;
case '[': printf("o"); break;
case 'p':
case 'P': printf("i"); break;
case 'o':
case 'O': printf("u"); break;
case 'i':
case 'I': printf("y"); break;
case 'u':
case 'U': printf("t"); break;
case 'y':
case 'Y': printf("r"); break;
case 't':
case 'T': printf("e"); break;
case 'r':
case 'R': printf("w"); break;
case 'e':
case 'E': printf("q"); break;
case 'w':
case 'W': printf("w"); break;
case 'q':
case 'Q': printf("q"); break;
case '"': printf("l");break;
case ';':
case ':': printf("k"); break;
case 'l':
case 'L': printf("j"); break;
case 'k':
case 'K': printf("h");break;
case 'j':
case 'J': printf("g");break;
case 'h':
case 'H': printf("f");break;
case 'g':
case 'G': printf("d");break;
case 'f':
case 'F': printf("s");break;
case 'd':
case 'D': printf("a");break;
case '/':
case '?': printf(",");break;
case '.':
case '>': printf("m");break;
case ',':
case '<': printf("n");break;
case 'm':
case 'M': printf("b");break;
case 'n':
case 'N': printf("v");break;
case 'b':
case 'B': printf("c");break;
case 'v':
case 'V': printf("x");break;
case 'c':
case 'C': printf("z");break;
case 'x':
case 'X': printf("x");break;
case 'z':
case 'Z': printf("z");break;
case '\'':printf("l");break;
case '=':printf("0");break;
case '-': printf("9");break;
case '0': printf("8");break;
case '9': printf("7");break;
case '8': printf("6");break;
case '7': printf("5");break;
case '6': printf("4");break;
case '5': printf("3");break;
case '4': printf("2");break;
case '3': printf("1");break;
case '2': printf("`");break;
default:printf("%c",l[i]);
}
}
printf("\n");
}
return 0;
}

*/

//10222
#include<stdio.h>

int main()
{
    char ch,x;
   
    while(scanf("%c",&x)==1)
    {
    if((x=='?')||(x=='/'))
    printf(",");
    if((x=='>')||(x=='.'))
    printf("m");
   
    if((x=='<')||(x==','))
    printf("n");
   
    if((x=='M')||(x=='m'))
    printf("b");
   
    if((x=='n')||(x=='N'))
    printf("v");
   
    if((x=='B')||(x=='b'))
    printf("c");
   
    if((x=='v')||(x=='V'))
    printf("x");
   
    if((x=='C')||(x=='c'))
    printf("z");
   
    if((x=='x')||(x=='X'))
    printf("x");
   
    if((x=='Z')||(x=='z'))
    printf("z");
   
    if((x=='"')||(x=='\''))
    printf("l");
   
    if((x==';')||(x==':'))
    printf("k");
   
    if((x=='l')||(x=='L'))
    printf("j");
   
    if((x=='K')||(x=='k'))
    printf("h");
   
    if((x=='j')||(x=='J'))
    printf("g");
   
    if((x=='H')||(x=='h'))
    printf("f");
   
    if((x=='g')||(x=='G'))
    printf("d");
   
    if((x=='F')||(x=='f'))
    printf("s");
   
    if((x=='d')||(x=='D'))
    printf("a");
   
    if((x=='S')||(x=='s'))
    printf("s");
   
    if((x=='a')||(x=='A'))
    printf("a");
   
    if((x==']')||(x=='}'))
    printf("p");
   
    if((x=='{')||(x=='['))
    printf("o");
   
    if((x=='p')||(x=='P'))
    printf("i");
   
    if((x=='O')||(x=='o'))
    printf("u");
   
    if((x=='i')||(x=='I'))
    printf("y");
   
    if((x=='U')||(x=='u'))
    printf("t");
   
    if((x=='y')||(x=='Y'))
    printf("r");
   
    if((x=='T')||(x=='t'))
    printf("e");
   
    if((x=='r')||(x=='R'))
    printf("w");
   
    if((x=='e')||(x=='E'))
    printf("q");
   
    if((x=='w')||(x=='W'))
    printf("w");
   
    if((x=='Q')||(x=='q'))
    printf("q");
   
    if((x=='|')||(x=='\\'))
    printf("-");
   
    if((x=='=')||(x=='+'))
    printf("0");
   
    if((x=='-')||(x=='_'))
    printf("9");
   
    if((x=='0')||(x==')'))
    printf("8");
   
    if((x=='9')||(x=='('))
    printf("7");
   
    if((x=='*')||(x=='8'))
    printf("6");
   
    if((x=='&')||(x=='7'))
    printf("5");
   
    if((x=='6')||(x=='^'))
    printf("4");
   
    if((x=='5')||(x=='%'))
    printf("3");
   
    if((x=='$')||(x=='4'))
    printf("2");
   
    if((x=='#')||(x=='3'))
    printf("1");
   
    if((x=='@')||(x=='2'))
    printf("`");
   
    if((x=='!')||(x=='1'))
    printf("1");
   
    if((x=='`')||(x=='`'))
    printf("`");
    if(x==' ')
    printf(" ");
   
     }
}

*/

UVA Solution for 10110

//10110
#include<stdio.h>
#include<math.h>

int main()
{
long int r;
 double num,root;

while(scanf("%lf",&num)==1)
    {
    if(num==0)
    break;

    r=sqrt(num);
    root=pow(r,2);

    if(root==num)
    printf("yes\n");
    else
    printf("no\n");
    }
return 0;
}

UVA Solution for 10079

//10079
#include<stdio.h>
int main()
{
long int pics,cut;
while(scanf("%ld",&cut)==1)
{
if(cut<0)
break;

pics=(cut*(cut+1)/2)+1;
printf("%ld\n",pics);

}
}

UVA Solution for 10071

//10071
#include <stdio.h>
int main()
{
    long int s,v,t;
    while(scanf("%ld%ld",&v,&t)==2)
    {
    s=v*t*2;
    printf("%ld\n",s);
    }
   
}

UVA Solution for 10055

//10055
#include <stdio.h>
#include <math.h>

int main()
{
long int has,opp,diff;
  while(scanf("%ld%ld",&has,&opp)==2)
{
    //printf("\nInput the number of soldiers in Hashmat's army\n");
  //  scanf("%ld",&has);
   // printf("\nEnter the number of soldiers in opponent's army");
   // scanf("%ld",&opp);
    diff=(has-opp);
    if(diff<0)
    diff=diff*-1;
    printf("%ld\n",diff);
}   
//getch();
}

UVA Solution for 10018

//10018
#include <stdio.h>
long int reverse(long int  n)
{
    long  int sum=0;
while(n>0)
     {
     sum=sum*10+n%10;
     n=n/10;
     }
     return sum;
}


int main(int argc, char *argv[])
{
    long  int tot,i,iter,n,sum=0,sum1=0,x=0;

while(scanf("%ld",&tot)==1)
{
  for(i=1;i<=tot;i++)
  {
  iter=0;
    scanf("%ld",&n);

    for(;;)
    {
 sum1=reverse(n);
 if (sum1==n)
  break;
 else
 n=n+sum1;
 iter++;
    }

    printf("%ld %ld\n",iter,sum1);
}
   }
   return 0;

}

UVA Solution for 913

//913
#include <stdio.h>
int main()
{
    long int n,sum,odd;
    while(scanf("%ld",&n)==1)
    {
    odd=(n*(n+2))/2;
    sum=(3*odd)-6;
    printf("%ld\n",sum);
    }
}


UVA Solution for 591

//591
#include<stdio.h>

int main()
{
int n,x[102],i,j,set=0,mov,sum,avg;

while(scanf("%d",&n)==1)
    {
  
   if(n==0)
   break;
set++;
    sum=0;
   mov=0;
   for(i=0;i<n;i++)
       {
      scanf("%d",&x[i]);
      sum+=x[i];
      }

   avg=sum/n;

   for(j=0;j<n;j++)
       {
      if(avg<x[j])
       mov+=x[j]-avg;
      }

  //  printf("Set #%d\nThe minimum number of moves is %d\n",set,mov);
  printf("Set #%d\nThe minimum number of moves is %d.\n\n",set,mov);
   }
   return 0;
}

UVA Solution for 438

//438
#include<stdio.h>
#include<math.h>
#define pi 3.141592653589793
int main()
{
 double x1,x2,y1,y2,x3,y3;
 double i,j,s,a,b,c,r;
 double cir;
 while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)==6)
 {

 a=sqrt(pow((x1-x2),2)+pow((y1-y2),2));
 b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
 c=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
 s=(a+b+c)/2;

r=a*b*c/(4*sqrt((s*(s-a)*(s-b)*(s-c))));
cir=2*pi*r;
printf("%.2lf\n",cir);
}
}

UVA Solution for 458

//458
#include<stdio.h>
int main()
    {
     char ch,x;
     while(scanf("%c",&ch)==1)
          {
           if(ch=='\n')
           printf("\n");
           else
               {
                x=ch-7;
                //to code x=ch+7;
                printf("%c",x);
               }
          }                   
    return 0;
    }
   

UVA Solution for 369

//369
#include<stdio.h>
double fact(double n)
       {
        if(n==0)
        return 1;
        else
        return (n*fact(n-1));
       }
     

int main()

    {
  double n,k,r;
  while(scanf("%lf%lf",&n,&r)==2)
 {
     if(n==0 && r==0)break;                          
  k=fact(n)/(fact(n-r)*fact(r));
  printf("%.0lf things taken %.0lf at a time is %.0lf exactly.\n",n,r,k);
}
    }

UVA Solution for 299

//299
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
   int temp,i,j,k,kase,len,x[100]={0};
   int swap;
   while(scanf("%d",&kase)!=0)
       {
        scanf("%d",&len);
        for(i=0;i<len;i++)
           {
            scanf("%d",&x[i]);
            }
        swap=0;  
          
          for(i=0;i<len;i++)
          {
          for(j=0;j<len;j++)
          {
           if( ( x[j]>x[j+1])&& (j!=len))
              {
               temp=x[j];
               x[j]=x[j+1];
               x[j+1]=temp;
               swap++;
              }
          }
          }
        
                      printf("Optimal train swapping takes %d swaps.\n",swap);
                          
       }
  
}

UVA Solution for 299

//299
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
   int temp,i,j,k,kase,len,x[100]={0};
   int swap;
   while(scanf("%d",&kase)!=0)
       {
        scanf("%d",&len);
        for(i=0;i<len;i++)
           {
            scanf("%d",&x[i]);
            }
        swap=0;  
          
          for(i=0;i<len;i++)
          {
          for(j=0;j<len;j++)
          {
           if( ( x[j]>x[j+1])&& (j!=len))
              {
               temp=x[j];
               x[j]=x[j+1];
               x[j+1]=temp;
               swap++;
              }
          }
          }
        
                      printf("Optimal train swapping takes %d swaps.\n",swap);
                          
       }
  
}

UVA Solution for 272

//272 uva
#include <stdio.h>
#include <string.h>
int main()
{
   int a=0;
    char ch;
    while(scanf("%c",&ch)==1)
             {
                             if(ch=='"')
                                        {
                                           a++;
                                           if((a%2)==1)
                                           printf("``");
                                           else if ((a%2)==0)
                                           printf("''");
                                        }
                             else
                             printf("%c",ch);
             }               
}

UVA Solution for 100

#include
int main()
{
long int i,j,n1,n2,max=0,l,temp;

while(scanf("%ld %ld",&n1,&n2)==2){
printf("%ld",n1);
printf(" %ld",n2);
max=0;

if(n2>1;
else i=3*i+1;
l++;
}
if(l>max) max=l;

}
printf(" %ld\n",max);
}
return 0;
}

UVA Solution for 113

//113
#include
#include

int main()
{
double n,p,k,t;

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

t=1/n;
k=pow(p,t);
printf("%.0lf\n",k);

}
}


/*
#include
#include

int main()
{
double x,k,n,p;

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

x=1/n;
k=pow(p,x);
printf("%.0lf\n",k);

}
return 0;
}
*/