Correct output in CMD but wrong answer in codechef.. help please :'(

#include
#include
#include
//Hey
#include <stdio.h>

using namespace std;

int main(){

int f, t, n;
int another;
vector <int> myVect;
int i=0;
scanf("%d",&n);
int temp;

for (i=0; i<n; i +=1)
{
	
	scanf("%d",&temp);
	myVect.push_back(temp);
	
	
}

for (int q=0; q<n; q++){

f = myVect.at(q);

another = 1;
int t = f;

for (t; t>0; t += (-1)){

	another = another * t;
}


 cout<<another<<endl;
 
 
	}


	return 0;

}

hey @aalok_sathe

Try running your code for input


1
100

Your code Cannot handle this case as

Constraints are:

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.

So that mean your code should be able to calculate maximum of 100 factorial and factorial of 100 is

93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000L

which cannot be stored in integer or floating point datatypes in c or c++, So you have to use array to store the number.

Now how to do that ?

For this problem check this link: discuss.codechef.com/questions/7349/computing-factorials-of-a-huge-number-in-cc-a-tutorial

That’s the reason of getting WA.
Hope you understood…! :slight_smile:

Above Answer is absolutely correct.I just want to add one more thing,You can calculate 100! using BiGInteger class in java.So its your choice,you can go either way.My suggestion is that go with @rishabhprsd7 bhaiya…You will learn a lot if you do it that way…