ACM Kanpur: Presti digitator. output file matching exactly, then why my code was showing wrong answer?

My code:
#include<stdio.h>
long double f(int m)
{
int i;
long double fa=1;
for(i=1;i<=m;i++)
{
fa=(long double)fa*i;
}
return fa;
}
int main()
{
int cases,n,i;
long double ans;
long double temp=0;
long long int abc;
scanf("%d",&cases);
while(cases–)
{
temp=0.0;
scanf("%d",&n);
if(n==0)
{
printf("%d\n",0);
continue;
}
for(i=0;i<=n;i++)
{
if(i%2==0)
temp+=(long double)(1.0/f(i));
else
temp-=(long double)(1.0/f(i));
//cout<<temp<<" “<<f(i)<<” “;
}
//cout<<temp<<endl;
ans=f(n)*temp;
abc=(long long int)ans;
if(ans-(long double)abc>0.8)
{
ans+=1.0;
abc=(long long int)ans;
}
printf(”%lld\n",abc);
}
return 0;
}
an accepted code:

#include <stdio.h>
inline void compute(int n)
{
long long int a=0,b=1,c,i=3;
if(n==1)
printf("%lld\n",a);
else
if(n==2)
printf("%lld\n",b);
else
{
for(i=3;i<=n;i++)
{
c=(a+b)*(i-1);
a=b;
b=c;
}
printf("%lld\n",c);
}
}
int main()
{
long long int i,n=0;
scanf("%lld",&n);
while(n–)
{
scanf("%lld",&i);
compute(i);
}
return 0;
}
i/p is restricted to be <=20 and is a +ve integer
o/p is only diff for 0 as i/p which is invalid for the situation in the question.
the accepted code displays junk for 0 i/p whereas, i display 0 o/p.
link to the problem: http://www.codechef.com/ACMKAN12/problems/PRESTI
this was very frustrating :frowning:

i/p is restricted to be <=20 and is a +ve integer o/p is only diff for 0 as i/p which is invalid for the situation in the question. the accepted code displays junk for 0 i/p whereas, i display 0 o/p

//