Getting wrong answer in problem code FCTRL2

Wrong Answer Error.
My Code
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;

for(int i=0;i<t;i++)
{ int A;
cin>>A;
long long int fact=1;
for(int i=A;i>0;i–)
{
fact=fact*i;
}
cout<<fact<<endl;
}
return 0;
}
I have tested on different numbers. it’s showing right answer but when i’m trying to submit my answer then it throwing wrong answer error.
please ! can you help me to identifying my mistakes.

1 Like

Input

An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100.

As per the given constraints, if an input value is 100 then the factorial value will be so large that even long long int data type won’t be able to store it.
You can go through this discussion to understand how to deal with it:

I got it after 4 long hours. Definitely not beginner level as mentioned.
#include <stdio.h>

int main()
{
int t;
scanf("%d",&t);
while(t–)
{
int prod,i,n,asize=1,x;
int rev[500];
rev[0]= 1;
scanf("%d",&n);
for(x=2;x<=n;x++)
{
int carry=0;
for(i=0;i<asize;i++)
{
prod=x*rev[i]+carry;
rev[i]=prod%10;
carry=prod/10;
}
while(carry!=0)
{
rev[asize]=carry%10;
carry=carry/10;
asize++;
}
}
for(i=asize-1;i>=0;i–)
{
printf("%d",rev[i]);
}
printf("\n");
}
return 0;
}