We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi, can someone help me with my code. I could pass only 1 test case. For other test cases it say terminated due to timeout.
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;intmain(){intbase,n;// cout <<" enter base" <<endl;cin>>base;// cout <<"Enter the value of n"<<endl;cin>>n;intarr[n];// cout <<"Enter the array"<<endl;for(unsignedinti=0;i<n;i++){cin>>arr[i];}for(inti=0;i<n;i++){longlongunsignedintfact=1;for(unsignedintj=1;j<=arr[i];j++){fact=fact*j;}// cout << fact << " ";while((fact%base)==0){fact=fact/10;}cout<<(fact%100000)<<endl;}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #160: Factorial trailing digits
You are viewing a single comment's thread. Return to all comments →
Hi, can someone help me with my code. I could pass only 1 test case. For other test cases it say terminated due to timeout.