I am fairly new to programming and are trying out some of the easy practice problems on codechef. I did this problem called Factorial( link: http://www.codechef.com/problems/FCTRL) and my submission succeeded, but i couldnt help noticing that my implementation was considerably slower than the most effective ones. 60 times slower in fact. To me, my code seemed pretty straight forward, no immense growth factors or anything like that. Here is my code:
#include<iostream>
using namespace std;
int main(){
ios_base::sync_with_stdio (false);
int t,n;
cin>>t;
for (int i=0; i<t; ++i){
int p=5;
int c=0;
cin>>n;
while(p<=n){
c=c+n/p;
p=p*5;
}
cout<<c<<'\n';
}
return 0;
}
So i wondered if there is any obvious statements in my code that hinder my performance greatly? Is it the way i handle I/O?