9Google AdSense

11461 Square Numbers

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

int main()
{
    long long int a,b,i,j,x,count,temp;
    double y;
    while(scanf("%lld%lld",&a,&b)==2)
    {
    if((a==0)&(b==0))
        break;
    if(a>b)
    {
     temp=a;
     a=b;
     b=temp;

    }
    count=0;
    x=0;
    for(i=a;i<=b;i++)
    {
         x=sqrt(i);
         if((x*x)==i)
          count++;


    }
    printf("%lld\n",count);
    }
    return 0;

}

10922 2 the 9s

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

int main()
{
     char ary[9000];
     int sum,i,len,n,a,b,c;
     while(gets(ary))
     {
    if((ary[0]=='0')&&(ary[1]=='\0'))
        break;
    c=0;
    sum=0;
    len=strlen(ary);
    for(i=0;i<len;i++)
        sum=sum+(ary[i]-48);

    if(sum%9==0)
    {
    if(sum!=9)
        c=1;
    do
    {
    n=sum;
    sum=0;

    while(n!=0)
    {
        a=n%10;
        b=n/10;
        n=b;
        sum=sum+a;
    }
    c=c+1;
    }while(sum>10);
    printf("%s is a multiple of 9 and has 9-degree %d.\n",ary,c);
    }
    else
        printf("%s is not a multiple of 9.\n",ary);
     }
     return 0;
}

11332 Summing digit

#include<stdio.h>


int main()
{
    long long int n,a,b,i,ary[100],sum;
     while(scanf("%ld",&n)==1)
     {
     if(n==0)
    break;
     do
     { sum=0;
     while(n!=0)
     {
    sum=sum+n%10;
    b=n/10;
    n=b;
     }
      n=sum;
     }while(sum>=10);
     printf("%ld\n",sum);
     }
     return 0;
}

11934 Magic formula

#include<stdio.h>


int main()
{
    long int test,a,b,c,d,l,i,j,fun,k;
    while(scanf("%ld%ld%ld%ld%ld",&a,&b,&c,&d,&l)==5)
    {
        if((a==0)&&(b==0)&&(c==0)&&(d==0))
            break;
        fun=0;
        k=0;

        for(j=0;j<=l;j++)
        {
          fun=a*j*j+b*j+c;
          if(fun%d==0)
              k=k+1;

        }
        printf("%ld\n",k);

    }
    return 0;


}

10929 You can say 11

#include<stdio.h>
#include<string.h>
#include<math.h>
//#include<stdlib.h>

int main()
{
    int a,i,temp,l,j,k,tem1,sub,tem2,len,num[2000],m,n,sum1,sum2,x;
    char str[2000],c;

     while(gets(str))
      {
        sum1=0;
        sum2=0;
        len=strlen(str);
        if((str[0]=='0')&&(str[1]=='\0'))
            break;
        k=1;
        for(l=0;l<len;l++)
        {
            num[k++]=str[l]-48;

        }
        for(m=1;m<=k;m=m+2)
            sum1=sum1+num[m];
        for(n=2;n<=k;n=n+2)
            sum2=sum2+num[n];
        if(sum1>sum2)
            sub=sum1-sum2;
        else
            sub=sum2-sum1;
//sub=abs(sum1-sum2);
        if(sub%11==0)
            printf("%s is a multiple of 11.\n",str);
        else
            printf("%s is not a multiple of 11.\n",str);
        for(x=1;x<=k;x++)
            num[x]=0;
          //    scanf("%c",&c);


       }
    return 0;


}

10038 Jolly

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

int main()
{
    int a[5000],u,n,ff[3000],i,j1,dif,flag;

    while(scanf("%d",&n)!=EOF)
    {
        flag=1;

        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(u=1;u<n;u++)
            ff[u]=0;
        for(j1=1;j1<n;j1++)
        {
            dif=(a[j1]-a[j1+1]);
            if(dif<0)
                dif=-dif;
            if((ff[dif]==0)&&dif<n)
                ff[dif]=1;
             else
            {
                flag=0;
                break;
            }


        }

        if(flag==1)
            printf("Jolly\n");
        else
            printf("Not jolly\n");
    }

      return 0;


}

11713 Abstract Names

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

int  main()
{
       int a,lenstr1,lenstr2,i,j,k,f,l,m,n,x,y;
    char str1[100],str2[100],x1,str3[100],str4[100];
    scanf("%d",&a);
    scanf("%c",&x1);
    for(i=1;i<=a;i++)
    {

        gets(str1);
        gets(str2);
        f=0;
        m=0;
        n=0;
        lenstr1=strlen(str1);
        lenstr2=strlen(str2);
        for(j=0;j<lenstr1;j++)
        {
            if((str1[j]=='a')||(str1[j]=='e')|| (str1[j]=='i')||(str1[j]=='o')||(str1[j]=='u'))
             ;
             else
                str3[m++]=str1[j];


        }
        for(k=0;k<lenstr2;k++)
        {    if((str2[k]=='a')||(str2[k]=='e')|| (str2[k]=='i')||(str2[k]=='o')||(str2[k]=='u'))
            ;
            else
                str4[n++]=str2[k];
        }
        if(m==n)
        {
        for(l=0;l<n;l++)
        {    if(str3[l]!=str4[l])
            {    f=1;
                break;
            }
        }
        }
        if((n!=m)||(f==1))
            printf("No\n");
        else
            printf("Yes\n");
        for(x=0;x<m;x++)
            str3[x]=0;
        for(y=0;y<n;y++)
            str4[y]=0;




    }
       return 0;

}

12468 - Zapping

#include<stdio.h>


int main()
{
    int a,b,count1,count2,l1,l2,sub,temp;
    while(scanf("%d%d",&a,&b)==2)
    {
        if((a==-1)&&(b==-1))
            break;
        count1=0;
        count2=0;
        if(b<a)
        {
            temp=a;
            a=b;
            b=temp;

        }
        count1=b-a;
            for(l1=a;l1!=b;l1--)
            {
                if(l1==-1)
                {    l1=99;
                    if(b==99)
                         break;
                }
                count2=count2+1;
            }



        if(count1<count2)
            printf("%d\n",count1);
        else
            printf("%d\n",count2);

    }

    return 0;


}
http://uva.onlinejudge.org/external/124/12468.html

12289 One-Two-Three

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

int main()
{
    int test,i,l,h,w;
    char str[50];
       // freopen("F:\\a.txt","r",stdin);
        scanf("%d",&test);
        for(i=1;i<=test;i++)
        {
            scanf("%s",str);
            l=strlen(str);
            if(l==3)
            {
                if((str[0]=='o')&&(str[1]=='n')||(str[0]=='o')&&(str[2]=='e')||(str[1]=='n')&&(str[2]=='e'))
                    printf("1\n");
                else if((str[0]=='t')&&(str[1]=='w')||(str[0]=='t')&&(str[2]=='o')||(str[1]=='w')&&(str[2]=='o'))
                    printf("2\n");
        }
        if(l==5)
        printf("3\n");
    }

        return 0;

}


10082 WERTYU


 Problem
#include<stdio.h>

#define max 50000

int main()
{
    int key[255]={0},i;
    char str[max];
    key[1]='`';
    key[2]='1';
    key[3]='2';
    key[4]='3';
    key[5]='4';
    key[6]='5';
    key[7]='6';
    key[8]='7';
    key[9]='8';
    key[0]='9';
    key['-']='0';
    key['=']='-';

    key['W']='Q';
    key['E']='W';
    key['R']='E';
    key['T']='R';
    key['Y']='T';
    key['U']='Y';
    key['I']='U';
    key['O']='I';
    key['P']='O';
    key['[']='P';
    key[']']='[';
    key[92]=']';
    key['S']='A';
    key['D']='S';
    key['F']='D';
    key['G']='F';
    key['H']='G';
    key['J']='H';
    key['K']='J';
    key['L']='K';
    key[';']='L';
    key[39]=';';
    key['X']='Z';
    key['C']='X';
    key['V']='C';
    key['B']='V';
    key['N']='B';
    key['M']='N';
    key[',']='M';
    key['.']=',';
    key['/']='.';
    key[32]=' ';


    while(gets(str))
    {

    i=0;
    while(str[i])
    {   if((str[i]>='0')&&(str[i]<='9'))
        {
        str[i]=str[i]-48;
        printf("%c",key[str[i++]]);
        }
        else if((str[i]!='Q')||(str[i]!='A')||(str[i]!='Z')||(str[i]!='`'))
        printf("%c",key[str[i++]]);
    }
    printf("\n");
    }

    return 0;
}