Tuesday, 1 March 2016

Codeforces Problem : 96A - Football


Problem Link :  codeforces.com/problemset/problem/96/A

Solve :

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

int main()
{
    char Football[200],Initial;
    int Loop,Length,Counter=1;

    scanf("%s",Football);

    Length=strlen(Football);
    Initial=Football[0];

    for(Loop=0; Loop<Length-1; Loop++)
    {
        if(Initial==Football[Loop+1])
        {
            Counter++;
            if(Counter>6)
                break;

        }

        else
        {
            Initial=Football[Loop+1];
            Counter=1;
        }
    }

    if(Counter>6)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;


}

Codeforces Problem : 4A - Watermelon


Problem Link : http://codeforces.com/problemset/problem/4/A

Solve:

#include<stdio.h>

int main()
{
    int w;

    scanf("%d",&w);

    if(w%2==0 && w>2)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

Codeforces Problem : 71A - Way Too Long Words


Problem Link :  http://codeforces.com/problemset/problem/71/A

Solve :

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

int main()
{
    char input[100];
    int length,test,Loop;

    scanf("%d",&test);

    for(Loop=1; Loop<=test; Loop++)
    {
        scanf("%s",input);

        length=strlen(input);

        if(length<=10)
            printf("%s\n",input);
        else
        {
            printf("%c%d%c\n",input[0],length-2,input[length-1]);
        }
    }

    return 0;
}

Codeforces Problem : 158A - Next Round


Problem Link :  http://codeforces.com/problemset/problem/158/A


Solve :

#include<stdio.h>

int main()
{
    int n,k,Loop,Check,Count=0,Zero_Count=0;

    scanf("%d%d",&n,&k);

    int Array[n];

    for(Loop=0; Loop<n; Loop++)
    {
        scanf("%d",&Array[Loop]);
    }


    Check=Array[k-1];

    for(Loop=0; Loop<n; Loop++)
    {
        if(Array[Loop]==0)
            Zero_Count++;

        else if(Check<=Array[Loop])
            Count++;
    }

    if(Zero_Count==n)
        printf("%d\n",0);
    else
        printf("%d",Count);

    return 0;

}

Codeforces Problem : 118A - String Task


Problem Link : http://codeforces.com/problemset/problem/118/A

Solve :

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


int main()
{
    char a[202];
    int Length,Loop1,Loop2,Loop3,Length1,Place=0,i=0;

    scanf("%s",a);

    Length=strlen(a);

    for(Loop3=0; Loop3<Length; Loop3++)
    {
        for(Loop1=0; Loop1<Length; Loop1++)
        {
            if(a[Loop1]=='a' || a[Loop1]=='A' || a[Loop1]=='e' || a[Loop1]=='E' || a[Loop1]=='i' || a[Loop1]=='I' ||a[Loop1]=='o' || a[Loop1]=='O' || a[Loop1]=='u' || a[Loop1]=='U'|| a[Loop1]=='y' || a[Loop1]=='Y')
            {
                for(Loop2=Loop1; Loop2<Length; Loop2++)
                {
                    a[Loop2]=a[Loop2+1];
                }

            }

        }
    }


    Length=strlen(a);
    Length1=Length;

    for(Loop1=0; Loop1<Length; Loop1++)
    {
        for(Loop2=Length1; Loop2>i; Loop2--)
        {
            a[Loop2]=a[Loop2-1];

        }
        a[Length1+1]='\0';
        Length1=Length1+1;
        if(i>=1)
            i=i+2;
        else
            i=i+1;
        a[Place]='.';
        Place=Place+2;

    }

    strlwr(a);

    printf("%s\n",a);

    return 0;

}

Codeforces Problem : 231A - Team

Problem Link :  http://codeforces.com/problemset/problem/231/A


Solve:

#include<stdio.h>

int main()
{
    int n,f1,f2,f3,Loop1,Count,AnsCounter=0,Loop2;

    scanf("%d",&n);

    for(Loop1=1;Loop1<=n;Loop1++)
    {
        Count=0;
        scanf("%d%d%d",&f1,&f2,&f3);

        if(f1==1)
            Count++;
        if(f2==1)
            Count++;
        if(f3==1)
            Count++;
        if(Count>1)
            AnsCounter++;

    }
    printf("%d\n",AnsCounter);

    return 0;


}