Tuesday 27 May 2014

SPOJ : ACT solution (Alpha Centauri Tennis)

Spoj:ACT question

Hints: 
The winner of the match is the winner of the last game

Solution:

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


int main()
{
    int t,n;
    char *s;
    scanf("%d",&t);
    s = (char*)malloc(1000);

    while(t--)
    {
       
        scanf("%d %s",&n,s);
n=strlen(s)-1;
        printf("%c\n",s[n]);
    }
return 0;

No comments:

Post a Comment

Binary Search Algorithm Variations and Problems

Binary Search is a simple algorithm but is tricky when it comes to implementing it. The lower and upper bounds have to be set carefully to...