#include<stdio.h>
int main()
{
int t,m,i,n,a[200];
scanf("%d",&t);
if(t>=1&&t<=100)
{
while(t–)
{
scanf("%d",&n);
if(n>=1&&n<=100)
{
a[0]=1;
m=1;
while(n!=0)
{
int temp=0;
for(i=0;i<m;i++)
{
int x=(a[i]*n)+temp;
a[i]=x%10;
temp=x/10;
}
while(temp!=0)
{
a[m]=temp%10;
temp=temp/10;
m++;
}
n–;
}
for(i=m-1;i>=0;i–)
printf("%d",a[i]);
}
}
}
return 0;
}
print answer for every test case in a new line .
1 Like
Just add
printf("\n");
after for loop from m-1 to 0:
i.e.
for(i=m-1;i>=0;i--) printf("%d",a[i]); } printf("\n"); } } return 0; }
And you’ll get AC.
Here is AC version of your code:
CodeChef: Practical coding for everyone .