Cod sursa(job #45782)
| Utilizator | Data | 1 aprilie 2007 21:42:12 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<fstream>
using namespace std;
int main(){
ifstream a("fact.in");
ofstream b("fact.out");
long int x;
a>>x;
long int c=-1;
if(x>1){
long int k=x*4+1;
long int z=1;
while(z<k){
z=z*5;
c++; }
long int q=z/5;
z=(z/5-1)/4;
c=0;
while(x!=0){
c=c+q*(x/z);
q=q/5;
x=x%z;
z=(z-1)/5; }
}else{
if(x==0){
c=1;}else{
c=5; } }
b<<c;
a.close();
b.close();
return 0;
}
