CAN ANYONe PLEASE TELL ME WHICH TEST CASE I AM GETTING WRONG
........................I HAVE TRIED ALL WHICH I COULD TRY IN THIS PROBLEM
http://www.spoj.pl/problems/M00PAIR/

     MY SOLUTION

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

int fun(char *s)
{
      int i,n;
    for(i=0;s[i]!='\0';i++);
    i=i-1;
    n=0;
    while(i>=0)
    {
               n=10*n+(s[i]-'0');
               i--;
    }
    return n;
}
void add(char *p,char *q,char *r)
{
     int c=0,i,temp;

     for(i=0;p[i]!='\0'&&q[i]!='\0';i++)
     {
                                       temp=p[i]-'0'+q[i] -'0' +c;
                                       r[i]=temp%10+'0';
                                       c=temp/10;
     }
          while(p[i]!='\0')
     {
                      temp=p[i]-'0'+c;
                      r[i]=temp%10+'0';
                      c=temp/10;
                      i++;
     }
      while(q[i]!='\0')
     {
                      temp=q[i]-'0'+c;
                      r[i]=temp%10+'0';
                      c=temp/10;
                      i++;
     }
     while(c!=0)
     {
                r[i]=c+'0';
                c=c/10;
                i++;
     }
     r[i]='\0';

}

main()
{      char
one[2000]="1",zone[2000]="0",dzero[2000]="0",ans[1005][2000],k[2000],l[2000],m[2000];

      int i,n,f,uo,oop;
      char s[6];;

      ans[0][0]='0';

      for(i=1;i<=999;i++)
      {
                       strcpy(k,one);

                       strcpy(l,zone);

                       strcpy(m,dzero);

                       add(k,m,zone);


                       add(zone,l,one);

                       strcpy(dzero,l);

                       oop=0;

                      uo=strlen(dzero);

                      for(f=uo-1;f>=0;f--)
                      ans[i][oop++]=dzero[f];
                       ans[i][oop]='\0';

      }
      while( (scanf("%s",s))!=EOF )
      {

              n=fun(s);

      printf("%s\n",ans[n]);

      }

      return 0;
}

*UTKARSH SRIVASTAV
CSE-3
B-Tech 3rd Year
@MNNIT ALLAHABAD*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to