I tried the problem FCTRL2. Created a solution that works even for 100!. I am getting correct output in codeblocks and other online compilers, but it gives large numbers (sometimes separated by dashes) in Ideone and codechef compiler.
why is this happening, is something inherently different in compiles like codeblocks and ideone ?
This is the code:
#include<iostream>
#include<string>
using namespace std;
void facto(int n){
int arr[200]={1};
int carry;
for(int i=1;i<=n;i++){
for(int j=0;j<200;j++){
int temp=arr[j]*i+carry;
arr[j]=temp%10;
carry=temp/10;
}
}
int x;
for(int i=198;i>=0;i--){
if(arr[i]!=0){
x=i;
break;
}
}
for(int i=x;i>=0;i--){
cout<<arr[i];
}
cout<<endl;
}
int main(){
int t;
cin>>t;
for(int i=0;i<t;i++){
int n;
cin>>n;
facto(n);
}
}