Saturday, 25 January 2014

Code Of The Day

SPOJ

Problem Code : FTCRL2

 

#include<stdio.h>
int main()
{
    int a,m,temp,i,x,t,j;
    int arr[1000];

    scanf("%d",&t);

    while(t--)
    {
        scanf("%d",&a);
        arr[0]=1;
        m=1;

        for(j=1; j<=a; j++)
        {
            temp = 0;
            for(i=0; i<m; i++)
            {
                x = arr[i]*j + temp;
                arr[i] = x%10;
                temp = x/10;
            }
   
            while(temp>0)
            {
                arr[m++] = temp%10;
                temp/=10;
            }            
        }
        for(i=m-1; i>=0; i--)
            printf("%d",arr[i]);
        printf("\n");
    }
    return 0;
}


 

No comments:

Post a Comment