Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Small Factorials-C code working on PC but not on code chef

$
0
0

helloo......my code is giving correct answer on PC but wrong on Code chef. Someone..please help me out what is wrong with this code.

http://www.codechef.com/viewsolution/3595694

#include<stdio.h>
void main()
{
    int a[200],k,num,b[100],i=0,j,m,n,temp,x,t;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d",&b[i]);
    }
    for(k=0;k<t;k++)
    {
        num=b[k];
        a[0]=1;
        for(i=1,m=1;i<=num;i++)
        {
            for(j=0,temp=0; j<=m-1 ;j++)
            {
                x=a[j]*i+temp;
                a[j]=x%10;
                temp=x/10;
            }
            for(;temp>0;j++,m++,temp/=10)
                a[j]=temp%10;
        }
        for(j=m-1;j>=0;j--)
            printf("%d",a[j]);
        printf("\n");
    }

}

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>